Forums

(MySQLdb.OperationalError) (2013, 'Lost connection to MySQL server during query') In website error log

I get this error at random times in my flask webapp hosted on pythonanywhere, it causes a 500 internal server error and it's pretty unpredictable since if occurs in random queries.

(MySQLdb.OperationalError) (2013, 'Lost connection to MySQL server during query')

I am using python 3.10 virtualenv, flask, flask-SQLAlchemy and below is a screenshot of my initialization code enter image description here

Please help me resolve this issue, it's quite a hindrance since the hosted app is quite important, note that this issue does not happen locally

Could you take a look at these posts

https://www.pythonanywhere.com/forums/topic/2465/

https://www.pythonanywhere.com/forums/topic/2465/