I’ve had this issue once or twice. Cleaning out the Lighting port has solved it each time. A plastic toothpick, gently applied, removed a nice little wad of lint each time. First sign of this (when I examined them prior to cleaning) was that the Lightning plug did not seat all the way into the port, and had a slightly spongy feel when inserted.
Not to say this is always the problem. It is almost certainly not. But it’s worth checking before looking for more complicated causes.
Note: Recently I found one of my Lightning cables had some crud on it, which turned out to be corrosion. It’s hard to see, but the results were similar to lint, in that for a while charing was unreliable. Cleaning (even gently) did not help in this case. All it did was remove the corosion, along with what little conductor was left.
Lesson: Be sure you don’t leave your Lighting cables dangling where the ends might get damp and/or dirty.