Magento MySQL – ‘Has Gone Away’ Error

ce-1.7.0.2databasedebuggingmagento-1.7

I'm having loads of weird issues on Magento CE 1.7.0.2. During normal operations, the site will occasionally produce a Magento Error Page (There has been an error processing your request) on both frontend and backend. Viewing the associated report, I see the following message:

"SQLSTATE[HY000] [2006] MySQL server has gone away"

Sometimes, but more rarely, the report message will read:

 Connection reset by peer

I have looked at the var > log > system.log and the MySQL has gone away error is accompanied by the following:

Warning: PDO::__construct(): MySQL server has gone away  in /var/www/html/domain.com/live/lib/Zend/Db/Adapter/Pdo/Abstract.php on line 129
Error while reading greeting packet. PID=1863  in /var/www/html/domain.com/live/lib/Zend/Db/Adapter/Pdo/Abstract.php on line 129

In addition to this, the following error seems to be happening on every request, as well as the MySQL has gone away errors:

 Warning: include(File.php): failed to open stream: No such file or directory  in /var/www/html/domain.com/live/lib/Varien/Autoload.php on line 93
 Warning: include(): Failed opening 'File.php' for inclusion

I have looked most of the articles I can find about this and tinkered with the database parameters till the cows came home but the error remains.

After following another QnA about the compiler, I notice that the admin page System > Tools > Compilation is completely blank. I think these are all related errors but any insight into debugging or causes would be so helpful.

I apologise if this is incoherent; I've been awake for about 42 hours, so please ask for any clarification. Thank you.

— update —

My server stack for clarity:

PHP 5.5.4 (PHP-FPM)
Nginx 1.4.2
MySQL 5.5.33

— update —

It occurs to me (after some sleep) that I never specified – the PHP codebase and the MySQL db are on separate hardware servers – very important to know if ya'll are going to help me!! I apologise.

Best Answer

This is mostly due to any of the below two reasons

  1. Server timed out and closed the connection.
    fix: try increasing the wait_timeout variable in your mysqld’s my.cnf/my.ini configuration file.
  2. Server dropped an incorrect or too large packet.
    fix : increase the maximal packet size limit by increasing the value of max_allowed_packet in my.cnf/my.ini file.

Please check in files if you are trying to get something that is taking too long or inapplicable.

Related Topic