I don’t know why but my Magento installation which was working fine yesterday, is not working now.
It is showing like this:
There has been an error processing your request
Exception printing is disabled by default for security reasons.
Error log record number: 1017219017231
Where I check in /var/report for this log record no. 1017219017231
a:5:{i:0;s:43:"SQLSTATE[08004] [1040] Too many connections";i:1;s:1633:"#0 /data/htdocs/xyz.com/magento/lib/Zend/Db/Adapter/Pdo/Mysql.php(96): Zend_Db_Adapter_Pdo_Abstract->_connect()
#1 /data/htdocs/xyz.com/magento/lib/Varien/Db/Adapter/Pdo/Mysql.php(251): Zend_Db_Adapter_Pdo_Mysql->_connect()
#2 /data/htdocs/xyz.com/magento/lib/Zend/Db/Adapter/Abstract.php(459): Varien_Db_Adapter_Pdo_Mysql->_connect()
#3 /data/htdocs/xyz.com/magento/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('SET NAMES utf8', Array)
#4 /data/htdocs/xyz.com/magento/lib/Varien/Db/Adapter/Pdo/Mysql.php(333): Zend_Db_Adapter_Pdo_Abstract->query('SET NAMES utf8', Array)
#5 /data/htdocs/xyz.com/magento/app/code/core/Mage/Core/Model/Resource/Type/Db/Pdo/Mysql.php(45): Varien_Db_Adapter_Pdo_Mysql->query('SET NAMES utf8')
#6 /data/htdocs/xyz.com/magento/app/code/core/Mage/Core/Model/Resource.php(93): Mage_Core_Model_Resource_Type_Db_Pdo_Mysql->getConnection(Object(Mage_Core_Model_Config_Element))
#7 /data/htdocs/xyz.com/magento/app/code/core/Mage/Core/Model/Resource/Setup.php(83): Mage_Core_Model_Resource->getConnection('core_setup')
#8 /data/htdocs/xyz.com/magento/app/code/core/Mage/Core/Model/Resource/Setup.php(160): Mage_Core_Model_Resource_Setup->__construct('core_setup')
#9 /data/htdocs/xyz.com/magento/app/code/core/Mage/Core/Model/App.php(399): Mage_Core_Model_Resource_Setup::applyAllUpdates()
#10 /data/htdocs/xyz.com/magento/app/code/core/Mage/Core/Model/App.php(329): Mage_Core_Model_App->_initModules()
#11 /data/htdocs/xyz.com/magento/app/Mage.php(627): Mage_Core_Model_App->run(Array)
#12 /data/htdocs/xyz.com/magento/index.php(80): Mage::run('', 'magento')#13 {main}";s:3:"url";s:22:"/magento/index.php/admin";s:11:"script_name";s:16:"/magento/index.php";s:4:"skin";s:7:"default";}
How to resolve this issue-:
"SQLSTATE[08004] [1040] Too many connections"
Log into your backend, use the customer maintenance dropdown to find the entry Online Customers and check the quantity. Sort by IP and stuff the results from the largest quantity into Bots Vs Browsers to see if they’re legit web indexers. You can temporarily 403 the traffic from specific IPs if it’s not.
If you cannot log into the back end, then you need to start doing server access log analysis to find out where all the traffic is coming from.
How to fix this problem. If you’re on shared hosting, you need to find something better. While increasing the max connections for MySQL on a dedicated server will help, that’s dependent on having enough iron on the backend to actually run the database with the increased load. Increasing max_connections indiscriminately can stop the error, but make the site deadly slow if the server is below par.
Get a page caching module so Magento isn’t being run every time a guest account loads a page. Combine this with APC cache to do opcode caching.
We’ve been intermittently experiencing this message during the last week because we got hit by Google, Bing, Yahoo, Baidu and Yandex deciding to refresh all at once. There was a security update for Litespeed web server that rendered its version 5.1 of php incompatible with APC cache and we had to disable it till we run an upgrade.
With Magento, the errors involving “Too many connections” or “Max connections exceeded” are telling you that your server is being overloaded. This can be because a) you have a weak server and it cannot keep up with your customers, b) your server was adequate for the number of users you expected, but you forgot that the requests generated by web indexers like Google are the majority of your traffic and must be calculated for, or c) you’re being hit by a DDOS attack.
Note: Under certain conditions, if you are not noticing overwhelming incoming traffic at this point in time, the mysql server may need to be restarted in order to reset record locks from a previous traffic spike that’s caused MySQL to exceed its connection limit.