I recommend taking a small wooden toothpick or a '''non'''-metallic tool small enough to fit into your charging port, and see if you can pick out any lint, hair, dust or debris. You can also try spraying compressed air into the charging port to help break up any blockages that can’t be removed by a toothpick.
Our phones spend a lot of time in our pockets, and sometimes lint, hair, dust and debris can get packed together, preventing your charging cable from making solid contact with the inside of your charging port.
[br]
I hope this helps!