Hi if this is happening when you are charging your phone try this,
Possible solution:
1. Use a different charger
2. Use a different charger/cable
3. check if there was any water damage, gently use a hair dryer at charging slot (optional as improper use may damage the slot further)
4. Factory reset
6. Service center