For a long time my Magento application was working fine. But suddenly it started showing this below error.

Fatal error: 
Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 2006 MySQL server has gone away' in /home/serverDir/public_html/lib/Zend/Db/Statement/Pdo.php:228 
Stack trace: 
#0 /home/serverDir/public_html/lib/Zend/Db/Statement/Pdo.php(228): PDOStatement->execute(Array) 
#1 /home/serverDir/public_html/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array) 
#2 /home/serverDir/public_html/app/code/core/Zend/Db/Statement.php(291): Varien_Db_Statement_Pdo_Mysql->_execute(Array) 
#3 /home/serverDir/public_html/lib/Zend/Db/Adapter/Abstract.php(479): Zend_Db_Statement->execute(Array) 
#4 /home/serverDir/public_html/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('insert into csv...', Array) 
#5 /home/serverDir/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(428): Zend_Db_Adapter_Pdo_Abstract->query('insert into csv...', Array) 
#6 /home/serverDir/public_html/app/code/local/namespace/module/Model/Observer.php(638): Varien_Db_Adapter_Pdo_Mysql->query('inser in /home/serverDir/public_html/lib/Zend/Db/Statement/Pdo.php on line 234

I searched all about this over internet, But could not find the solution.

Please guide me as to why suddenly it started showing this fatal error.

3 Answers 3


The usual cause when you get MySQL server has gone away is timeout errors and max_allowed_packet being set too low. These are settings that will have to be made to your system’s my.cnf file by your hosting provider.

MySQL Server has gone away causes from MySQL.com

The connection to your MySQL server is timing out due a PHP script taking too long to execute, server overload, wretchedly huge requests or a misconfiguration of MySQL

my.cnf settings that might help…

max_allowed_packet = 16M
wait_timeout = 1800 
connect_timeout = 120

You will need to restart your MySQL server for these settings to load

Try bumping max_allowed_packet incrementally up, you may need 24M-32M.

If you're on shared hosting, it's a good indicator that your shared host is running out of resources and Magento over time has due to database growth, exceeded the shared hosting capabilities to run it.


You need to increase the limit of max_allowed_packet of your mysql to say 30M or something.

In my linux installation this can be found in /etc/mysql/my.cnf file.

  • Thanks, Is it possible to set max_allowed_packet in php file. Commented Nov 1, 2014 at 6:15
  • Yes, you can issue the SQL SET GLOBAL max_allowed_packet=... to change the value of max_allowed_packet, but as it is a global variable be aware that you have to reconnect for the change to become effective because changing global system variables does not affect currently open connections. Commented Nov 1, 2014 at 6:25
  • not worked brother Commented Nov 1, 2014 at 7:05

Try to refresh indexes in Magento in System > Index Management. I've had the same problem and refreshing indexes helped.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.