1. Try a different cable
Charging cables can sometimes become worn out. If you have access to a spare, try swapping them. You can also try a different wall plug adapter.
2. Check for lint or debris in the charging port
Sometimes pocket lint or debris can become lodged in the charging port, preventing a connection. You can shine a light (such as a phone flashlight) into the charging port and see if you can identify anything. The cable may also feel loose when plugged in.
You can use a toothpick or paperclip to try to dislodge any lint, however be careful not to damage any of the connections.