Issue of database connection lost getting error 2013, 'Lost connection to MySQL server during query'

We are facing the database connection error 2013, ‘Lost connection to MySQL server during query’ in the UAT server(LAMBDA).

This error is coming randomly like once or twice a week, for the solution I use to push any kind of code (no matter what it can be a comment also) or I restart the database then the problem instantly resolves.

But I’m looking for a permanent solution, please help me to get over of it

Thank you

I faced this error when I run the next command on pythonanywhere.com

python manage.py migrate --fake my_app zero

Unfortunately I don’t know the permanent solution for this error massage.
But the problem was in my migrations files , I deleted it all and rerun makemigrations and migrate again and everything works .

But be careful my database on pythonanywhere.com is for testing it has no data so I feel free to DROP it or delete anything I want .

But in your case make sure to make backup for everything before taking any action .
I have just shared with you the same error occurred to me

Hope to find a solution for this annoying error