It can be stressful when your phone dies, but even more stressful when you plug it in and find that it won't charge.
When this happens with Android phones, it could be for a few different reasons. There may be an external issue, like a bad power outlet or worn charging cable. It may also be an internal problem like a software glitch.
Accordingly, you'll likely have to try a few different troubleshoot methods until the problem is solved.