Troubleshooting/debugging connection resets

I have an intermittent error on our databases (Percona MySQL 5.6 on
Debian 8) which I haven’t been able to find information about online - my colleague runs a python script and it occasionally gets kicked out with:

ConnectionResetError: [Errno 104] Connection reset by peer

As I understand it, this is because mysqld for some reason decides to reset the connection. Is there any way that I can get to see what causes mysqld to do this? The logs don’t show anything.

Hi,    any MySQL connections will timeout after being inactive for more than “wait_timeout”.  The default is 8h (28800s).  If that is not the case, is there a NAT router in between?  If the script runs in docker, be aware the host performs NAT for the containers and if I am remember well, the default linux timeout for TCP connections is 15min.