TEST TO DETERMINE WHERE THE MISALIGNMENT IS HAPPENING
Most of the time, the problem with a door that refuses to latch is that the latch isn’t aligned with the strike plate hole where it’s supposed to settle, thereby keeping the door shut.
To test latch misalignment, apply lipstick to the strike plate. Close the door. Open the door. The lipstick marks indicate where the latch contacts the strike plate.
TEST TO DETERMINE WHERE THE MISALIGNMENT IS HAPPENING
The strike plate should be moved until it is perfectly aligned with the latch. Then the door will close correctly. Strike plates should be removed before installing new ones. A sharp chisel hammer should be used to enlarge the mortise.
If the latch still doesn't work after adjusting the strike plate, there's something else wrong with your door. You may need to replace the entire door assembly, but first, try some of the following fixes.
Older doors can sag at the hinges when gravity pulls them down. You can try tightening them to get your door back on the straight and narrow, but you may also need to replace them with slightly longer screws to provide more support.
You can also use a hammer to loosen the old screws. Drive the head of the hammer into the screw until it pops out. Then remove the screw and drive another one in its place. Repeat this process for all the screws.
Remove the door from the frame by lifting the door off the track. Unscrew the two hinge pins on each side of the door. Slide the new pins into their respective holes. Screw the pins back into place. Replace the door on the frame.