Reputation:
I have a Django app running on Apache with wsgi module. After few hours of inactivity I get that error and I have to restart the Apache.
Any ideas?
Thanks
Upvotes: 0
Views: 604
Reputation: 4794
This error message mean that the database server has closed the connection to you. I guess this is caused because the connection is idle.
I believe you can get this fixed by adjusting the wait_timeout inside the configuration file of your mysql database server. The file is most commonly named "my.cnf".
This, however, is not considered as a good practice. I would like to suggest you to optimize the application you are writing to open the connection to mysql on demand - there's no point to keep it open if you are not actively using it for a long time.
If you need a quick fix, use the mysql_ping() function to check whether the connection is still alive and re-open if necessary.
Upvotes: 2