Chosen Solution
My computer won’t work unless it is connected to the charger. If it is off the charger, the computer will not power up.
It may be time to change batteries. or the power input port may be partially broken to not letting the battery charge. HP are easy to change as they are usually a plug in on the motherboard and not solder on . Hope this helps
The battery may be a faulty one if it is unable to retain a charge. If there is an issue with the battery then you should replace it.