There are several reasons why a laptop will no longer charge properly. Check the socket and connection first, as these are easily recognizable problems and easy to repair. If there's nothing wrong with that, changing your laptop's settings or resetting battery management can sometimes solve the problem. If that doesn't work, you may need to replace the battery.
Steps
Part 1 of 3: Troubleshooting

Step 1. Unplug the laptop for a few minutes and then try another one
Unplug the laptop, wait a few minutes, and then plug it into a wall outlet in another room. Some users report that a laptop adapter may temporarily stop working to protect itself from a perceived power problem.
If your battery is removable, only do this when the adapter is not connected to the mains. Press and hold the laptop's power button for two minutes, then reinsert the battery and plug the adapter into a new power outlet

Step 2. Examine the power cable
Check the entire length of the cord for cracks, dents, and wear on the insulation material. If you notice anything, or if the adapter itself is bent or smells like plastic, the cord is probably damaged. You will need to purchase a new power cable for your laptop.
Check your warranty conditions before replacing parts. Under certain circumstances, the costs may be borne by the manufacturer

Step 3. Inspect the connection
If the connection of the cord on your laptop is loose or wobbly, there may be a problem with the connection. Unplug the cord, remove any dirt with a toothpick and dust with compressed air.
Bent pins and other damage may vary by model. Take the laptop or cord to a repair technician. You can look up your laptop model online for proper repair instructions, but doing so can be difficult without the right tools and may void your warranty

Step 4. Restart the computer, first removing the battery
Turn off your computer, disconnect it from the power outlet, and then remove the battery from your laptop. The battery can usually be disconnected from the bottom of the laptop, whereby a lock may have to be turned with the help of a coin, or by means of a sliding lever. Leave the battery out for 10 seconds, click it back into the laptop and restart your computer. Plug the laptop's adapter back into the power socket after booting and wait 10 seconds before checking if it worked.
Not all laptops have a battery that you can easily access. If there is no obvious battery compartment, start your computer without removing the battery

Step 5. Let the computer cool down
If the battery feels very hot, excess heat can adversely affect the charging process. Turn off the computer and let it cool for a few minutes. If you haven't recently cleaned your laptop's fans, use compressed air to clear the fans from dust with short bursts of air from an angle.
- Do not blow directly into the exhaust of the fans, only at an angle, otherwise you could damage the fan.
- If you're brave enough to take your laptop apart, you can use the compressed air to instantly blow away the dust inside the case. Find a manual for disassembling your laptop model before you start, and work on a large and clean surface. This will most likely cause you to lose your warranty.

Step 6. Boot your laptop without battery
Turn off the computer, remove the battery and connect the computer to the power supply. If the computer won't turn on, you probably need a new cord. If the laptop is able to start up in this capacity, then the charging problem is probably related to the batteries themselves, or the way your computer communicates with the battery. The methods below may solve the problem, or your battery may be dead and will need to be replaced.
If your battery is non-removable, skip this step and try the methods below before getting the laptop repaired

Step 7. Replace the charger
Sometimes the adapter no longer works properly, or despite frantic efforts, it is not possible to repair a loose plug. If possible, borrow a charger from someone else, or ask a technician from a computer store to test your charger. If your charger is faulty, buy a new one from a computer or electronics store.
Part 2 of 3: Settings and drivers (Windows)

Step 1. Check the power management settings
Go to Start → Control Panel → Power Options. The 'low battery level' setting may be set too high, causing your computer to turn off instead of charging. The easiest way to deal with this is to reset them to their default settings. If this didn't resolve the issue, continue with the information below

Step #2. Open Device Manager
First, open 'Device Manager'. You can find these very easily in Windows by using the search function, or via Start → Control Panel → System and Security → Device Manager.

Step 3. Look at the settings for the Batteries
When the list is loaded, expand 'Batteries'.

Step 4. Update driver software
Right click on 'Microsoft ACPI-Compliant Control Method Battery,' and select 'Update Driver Software.' Follow the instructions that appear.

Step 5. Restart the computer
Shut down and restart the computer so that the driver is activated. If the laptop still won't charge, repeat the 'Update driver' step for each entry in the Battery section, and restart your computer a second time.

Step 6. Uninstall and install the driver
If you still can't charge your laptop, right click on 'Microsoft ACPI-Compliant Control Method Battery' and select 'Uninstall.' When the process is finished, click the button on the toolbar labeled Scan for hardware changes. Alternatively, you can open the 'Action' tab and select 'Scan for hardware changes'. Restart your computer after the driver has been reinstalled.
This step requires that you have an internet connection on your laptop
Part 3 of 3: Settings and drivers (Mac)

Step 1. Check your power management settings
Open System Preferences from the Dock in the Applications folder. Click Energy Saver and check both 'Battery' and 'Power Adapter'. In rare cases, a low sleep setting can cause it to appear as if there is a problem with charging. In most cases, you will need to try the additional steps below.

Step 2. Reset the System Management Controller
Use one of these methods to reset the SMC, which checks battery management and the battery status light:
-
Laptops with a non-removable battery:
Turn off the computer. Plug it into the socket. Press the shift control option keys on the left side at the same time and the power button on the laptop. Release the keys at the same time and turn your computer back on.
-
Laptops with a removable battery:
Turn off the computer and unplug the power cord. Remove the battery. Press and hold the power button for 5 seconds. Replace the battery and plug it back into the wall socket, after which you restart the computer.