0

Hi i have my magento running in amazon ec2 linux instance but frequently i get errors stating below mentioned errors

SQLSTATE[HY000] [2003] Can't connect to MySQL server on '127.0.0.1' (111)

Trace:
#0 /var/www/html/trial/lib/Zend/Db/Adapter/Pdo/Mysql.php(96): Zend_Db_Adapter_Pdo_Abstract->_connect()
#1 /var/www/html/trial/lib/Varien/Db/Adapter/Pdo/Mysql.php(320): Zend_Db_Adapter_Pdo_Mysql->_connect()
#2 /var/www/html/trial/lib/Zend/Db/Adapter/Abstract.php(459): Varien_Db_Adapter_Pdo_Mysql->_connect()
#3 /var/www/html/trial/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('SET NAMES utf8', Array)
#4 /var/www/html/trial/lib/Varien/Db/Adapter/Pdo/Mysql.php(428): Zend_Db_Adapter_Pdo_Abstract->query('SET NAMES utf8', Array)
#5 /var/www/html/trial/app/code/core/Mage/Core/Model/Resource.php(169): Varien_Db_Adapter_Pdo_Mysql->query('SET NAMES utf8')
#6 /var/www/html/trial/app/code/core/Mage/Core/Model/Resource.php(110): Mage_Core_Model_Resource->_newConnection('pdo_mysql', Object(Mage_Core_Model_Config_Element))
#7 /var/www/html/trial/app/code/core/Mage/Core/Model/Resource/Setup.php(141): Mage_Core_Model_Resource->getConnection('core_setup')
#8 /var/www/html/trial/app/code/core/Mage/Core/Model/Resource/Setup.php(234): Mage_Core_Model_Resource_Setup->__construct('core_setup')
#9 /var/www/html/trial/app/code/core/Mage/Core/Model/App.php(417): Mage_Core_Model_Resource_Setup::applyAllUpdates()
#10 /var/www/html/trial/app/code/core/Mage/Core/Model/App.php(343): Mage_Core_Model_App->_initModules()
#11 /var/www/html/trial/app/Mage.php(684): Mage_Core_Model_App->run(Array)
#12 /var/www/html/trial/index.php(87): Mage::run('', 'store')
#13 {main}

But once if i restart my apache and mysql again my site starts working perfectly and after some time the same error occurs initially my site was running in localhost after migrating to amazon linux instance i changed the secure base url and unsecure base url pointing towards my amazon linux instance public ip.

I have tried reindexing data.

so my question is 1.Where do i need to make changes so that my mysql will connect to my public ip instead of localhost(127.0.0.1). 2.what should i do so that this error won't happen again.

Thanks in advance.

0

Is sounds like your MySQL process is dropping. If you're running MySQL and Apache on the same instance and it's running out of memory the MySQL process will be killed.

2 solutions:

  1. Split your web and database nodes (On AWS look at RDS)
  2. Go for a bigger AWS instance with more memory
  • But how do i change my mysql server to point towards my public ip instead of localhost. Because mysql server shows can't connect to 127.0.0.1 – megamage Jul 7 '14 at 11:01
  • can anyone suggest me how to do this. – megamage Jul 7 '14 at 12:19
  • It won't be able to connect to 127.0.0.1 if the process has dropped (mysql isn't running). Because you said it works after you restart apache/mysql it means it is connecting to 127.0.0.1 (mysql) and is working but at some point mysql stops responding/quits which is why you're getting the error. See my answer above about the most likely reason. – john-jh Jul 7 '14 at 13:11
  • i did swapping and increased the space,and my problem was ruled out.Thanks for your suggessions. – megamage Aug 29 '14 at 8:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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