Failed to connect to MySQL. How to fix (3)?

When scripts work intensively jerking the database in Django admin 2.2 begins to periodically issue such a mistake, the scripts are working perfectly and do not fall.
Lost connection to MySQL server at 'reading initial communication packet', system error: 95


What could be wrong? In Django or in the database or what else? How to fix?

OS: Ubuntu 18.04
Database: MariaDB 10.4.7

Python 3.6.8
Django 2.2

This question is already asked, he sort of did, but then surfaced again.
Failed to connect to MySQL. How to fix?

The fact that the permanent connection I also can not stand, otherwise it is:
Failed to connect to MySQL. How to fix (2)?
And the fact that CONN_MAX_AGE in settings.py must be less than wait_timeout in my.cnf, otherwise
(2006, 'MySQL server has gone away')

And if you do not do constant, then
Lost connection to MySQL server at 'reading initial communication packet', system error: 95


Plus the problem is not only diange in any scripts. The problem is only when running the script is pretty much tormenting base in many threads. Maybe you can somehow configure something in the config to not fall off? What can be done?

Config: https://pastebin.com/APnFMiSc
April 7th 20 at 10:42
2 answers
April 7th 20 at 10:44
Solution
pool you need

Googly python mysql connections pool ORM
Thanks, I'll try - Kaycee.Ja commented on April 7th 20 at 10:47
Yes, it helped, thank you - Kaycee.Ja commented on April 7th 20 at 10:50
April 7th 20 at 10:46
what there should be....

in meeting the service needs to bandit the ip address to connect?
no resolves host names, connect only by IP?
to cut down everything that remotely resembles the firewall?
There are 2 servers, one database and admin panel for Ganga on the second scripts.
Jung to connect to the database is on 127.0.0.1:3306
On the second server, made a port forward rule for ssh and also connect to 127.0.0.1:3306
firewall? iptables or something to cut down? maybe some rules there and left.. - Kaycee.Ja commented on April 7th 20 at 10:49

Find more questions by tags MySQL