Showing results for 
Search instead for 
Did you mean: 

Site crashing intermittently - DB issue “Can't connect to MySQL server on 'db01'”

Site crashing intermittently - DB issue “Can't connect to MySQL server on 'db01'”

We have serious issue we cannot seem to figure out. Need help please. Randomly early last month we started to notice in our var/report logs around 80 times a day we are generating this same error message that is created by various pages when loaded on our site. When this error happens the Magento crash page will occur do to lack of DB connection. Here is the error:


 a:4:{i:0;s:76:"SQLSTATE[HY000] [2003] Can't connect to MySQL server on '' (4)";i:1;s:3368:"#0 /mtn/nfs/ Zend_Db_Adapter_Pdo_Abstract->_connect()
#1 /mtn/nfs/ Zend_Db_Adapter_Pdo_Mysql->_connect()
#2 /mtn/nfs/ Varien_Db_Adapter_Pdo_Mysql->_connect()
#3 /mtn/nfs/ Zend_Db_Adapter_Abstract->query('SET NAMES utf8', Array)
#4 /mtn/nfs/ Zend_Db_Adapter_Pdo_Abstract->query('SET NAMES utf8', Array)
#5 /mtn/nfs/ Varien_Db_Adapter_Pdo_Mysql->query('SET NAMES utf8')
#6 /mtn/nfs/ Mage_Core_Model_Resource->_newConnection('pdo_mysql', Object(Mage_Core_Model_Config_Element))
#7 /mtn/nfs/ Mage_Core_Model_Resource->getConnection('core_write')
#8 /mtn/nfs/ Mage_Core_Model_Resource_Db_Abstract->_getConnection('write')
#9 /mtn/nfs/ Mage_Core_Model_Resource_Db_Abstract->_getWriteAdapter()
#10 /mtn/nfs/ Mage_Core_Model_Resource_Db_Abstract->_getReadAdapter()
#11 /mtn/nfs/ Mage_Core_Model_Resource_Db_Abstract->getReadConnection()
#12 /mtn/nfs/ Mage_Core_Model_Resource_Db_Collection_Abstract->__construct(Object(Mage_Core_Model_Resource_Website))
#13 /mtn/nfs/ Mage_Core_Model_Config->getModelInstance('core_resource/w...', Object(Mage_Core_Model_Resource_Website))
#14 /mtn/nfs/ Mage_Core_Model_Config->getResourceModelInstance('core/website_co...', Object(Mage_Core_Model_Resource_Website))
#15 /mtn/nfs/ Mage::getResourceModel('core/website_co...', Object(Mage_Core_Model_Resource_Website))
#16 /mtn/nfs/ Mage_Core_Model_Abstract->getResourceCollection()
#17 /mtn/nfs/ Mage_Core_Model_Abstract->getCollection()
#18 /mtn/nfs/ Mage_Core_Model_App->_initStores()
#19 /mtn/nfs/ Mage_Core_Model_App->_initCurrentStore('', 'store')
#20 /mtn/nfs/ Mage_Core_Model_App->run(Array)
#21 /mtn/nfs/ Mage::run('', 'store')
#22 {main}";s:3:"url";s:10:"/markdowns";s:11:"script_name";s:10:"/index.php";}


In working with the hosting company we have already tried a few things. We have three dedicated servers. Front-end, back-end & DB. When we get the error shown above, the same time we get an error on the DB side.

2016-05-27 12:21:55 5949 [Warning] Aborted connection 13527446 to db: 'dbnameexample' user: 'usernamexample' host: '' (Got timeout reading communication packets).

Our hosting company recommended pushing our connection timeouts from 60s, to 360s. And our max packet size from 16MB to 256MB. These changes helped with our timeout communication packets on the DB. But we are still getting "Can't connect to MySQL server" errors.

We think the next avenue to pursue is to look at why Magento is giving up so soon when the database is clearly online and available. Perhaps this is a php retry or maybe a socket timeout of some kind. We have already pushed the php socket timeouts up to higher values. Any ideas would be greatly appreciated.



Re: Site crashing intermittently - DB issue “Can't connect to MySQL server on 'db01'”

You probably have limited number on connections available to MySQL and this number has been exhausted. Either those connection have been left hanging (in which case restarting MySQL helps) or you need to reconfigure it to allow more.

Tanel Raja