When you find the door rattles when closed in its frame, slightly adjust the latch plate the door latch sits against. This will hold the latch a bit tighter which might be enough to stop a door rattling when closed.
Make sure all the hardware is snug - hinges, doorknob, strike plate. Put in some weatherstripping all around the frame where the door contacts it (not the hinge side unless that's still wide open). That gives you a soft place for the door to rest snugly against and reduce vibration.
Tightening the screws or moving the hinge slightly can often resolve the problem. Additionally, placing a small washer behind one of the hinges can create enough friction to stop the door from moving on its own.
If the door rattles or shifts over an inch, the hinges are likely worn out or broken and will need replacement. For minor looseness though, the screws have probably just come loose from the frame and door. This is an easy DIY fix.
Shake, rattle and roll: Your door rattles when it's closed
One might think that if your door is closed, rattling would be impossible – but sadly not! The most likely issue is that the door wasn't quite fitted properly, and the latch is not positioned correctly in the strike plate.
If there is a gap between the door leaf and the frame, it can cause the door to rattle whenever a breeze passes through the frame.
Hairspray can be a quick and easy way to stop a door hinge from squeaking. Hairspray contains polymers that create a seal around the door hinges that stops them from loosening and moving about and squeaking. Spray a couple of times on the squealing hinge and then open and close the door to spread the hairspray around.
Sounds like your foundation has settled in an uneven way. Do you have a basement or crawlspace? I'd look under there. Maybe the ground wasn't properly prepared and compacted, or you have a high water table.
Tighten the Hinges First
If you find that the latch contacts the strike plate too high or too low, make sure all the door's hinge screws are tight. If that doesn't solve the problem, try this trick: Remove one of the screws on the jamb side of the hinge and drive in a 3-in. screw.
When you find the door rattles when closed in its frame, slightly adjust the latch plate the door latch sits against. This will hold the latch a bit tighter which might be enough to stop a door rattling when closed.
The first thing to do is to make sure that your door frame is securely screwed or bolted into place. You can also install special bars for added security by fitting them in key points like hinges and locks so they're sturdier than before.
To fix a door that won't stay shut, check the hinges and tighten any loose screws, adjust the strike plate so the latch fits, use shims between the hinges and the frame, or replace the hinge pins with longer, thicker pins. If the problem persists, seek professional help.
Tap the hinge pin from the top with a hammer until it aligns perfectly with the hinge. Test the door to see if it's still swinging. If it is, remove the faulty hinge pin, bend it further using a hammer, and place it back in the hinge until the door stops swinging open.
One of the most common causes of a frequently loose lever door handle is handle misalignment. This misalignment causes tension within the door handle assembly, resulting in gradually loosening screws and increased wear.
The most likely reason for your door opening and closing on its own is because the wall surrounding the door is likely leaning one way or the other. Gravity does the rest then and causes the door to move even when you aren't touching it. The key to fixing a door like this is to deal with hinges.