In order to clean the MagSafe port and connector, you’ll need to have unobstructed access to both.

Always be careful with your computer’s battery. Once you’ve got it out, set it aside someplace where it won’t be dropped or have something spilled on it. Though it’s unlikely, cleaning an electronic device with an active battery could result in a shock to you or damage to the device. [4] X Research source

It’s important that the object you use be completely dry. Never apply cleaning sprays or any other liquids to your computer’s open connections. [6] X Research source Make sure the toothbrush or cotton swab is clean to avoid transferring dirt and other substances. Avoid using metal objects, such as paperclips, inside the charging port. Not only can this interfere with the port’s magnetic properties, it’s also an electrical hazard.

If you haven’t cleaned your computer’s charging port in a while, you can use the point of a toothpick to break up caked-on dirt and grime. [9] X Research source Make sure that no fibers of any kind are left behind inside the port’s pin receptacles. [10] X Research source

Scrub vigorously to remove gunk that’s solidified around the edges of the connector. Don’t worry about displacing the charging pins. They’re designed to move freely when you touch them.

If the pins are still stuck after multiple attempts, press them sideways with your fingertip to pop them back into place. [13] X Research source Careful and regular cleaning around the charging pins will make them less likely to stick in the future.

Turn the computer on and look for the icon indicating that it’s charging to appear. [15] X Research source If the adapter frequently comes out of place, it may be due to a bad magnetic connection. In this case, buying a new charger might be your only option.

Refrain from eating or drinking around your computer as much as possible. [17] X Research source Consider cleaning more frequently if you share your household with pets or tend to use your computer outdoors.

Compressed air is also useful for tidying up around the battery compartment, adapter and other components with narrow openings. [19] X Research source Don’t forget to replace the battery when you’re done.

Faulty chargers can often be replaced at no cost to you. Take your charger to an Apple store to have it inspected for flaws. Check the warranty information included with your computer’s owner’s manual to see what types of issues it covers.