MySQL server has gone away (PHP)

Author: Zeeshan Arshad     1997     10/18/2011

Estimated reading time: 0 minutes, 18 seconds

Zeeshan Arshad - Lifestyle Blog

Problem: Server returns the error "Mysql server has gone away" when running a large set of queries (specially as a Cronjob).


Solution: Simply copy/paste the following lines in beginning of your php file.


ini_set('mysql.connect_timeout', 300);
ini_set('default_socket_timeout', 300);


Reason: The mysql.connect_timeout option is the reason for this.

« Return to Blog