0

I got the file backup from my live site and created a project in xampp/htdocs folder. And then connected it to a old database. When i am running the project in browser i got below error;

a:4:{i:0;s:92:"SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: No such host is known. ";i:1;s:2553:"#0 C:\xampp\htdocs\test\lib\Zend\Db\Adapter\Pdo\Mysql.php(109): Zend_Db_Adapter_Pdo_Abstract->_connect()
C:\xampp\htdocs\test\lib\Varien\Db\Adapter\Pdo\Mysql.php(320): Zend_Db_Adapter_Pdo_Mysql->_connect()
C:\xampp\htdocs\test\lib\Zend\Db\Adapter\Abstract.php(460): Varien_Db_Adapter_Pdo_Mysql->_connect()
C:\xampp\htdocs\test\lib\Zend\Db\Adapter\Pdo\Abstract.php(238): Zend_Db_Adapter_Abstract->query('SET NAMES utf8', Array)
C:\xampp\htdocs\test\lib\Varien\Db\Adapter\Pdo\Mysql.php(428): Zend_Db_Adapter_Pdo_Abstract->query('SET NAMES utf8', Array)
C:\xampp\htdocs\test\app\code\core\Mage\Core\Model\Resource.php(169): Varien_Db_Adapter_Pdo_Mysql->query('SET NAMES utf8')
C:\xampp\htdocs\test\app\code\core\Mage\Core\Model\Resource.php(110): Mage_Core_Model_Resource->_newConnection('pdo_mysql', Object(Mage_Core_Model_Config_Element))
C:\xampp\htdocs\test\app\code\core\Mage\Core\Model\Resource\Db\Abstract.php(320): Mage_Core_Model_Resource->getConnection('core_write')
C:\xampp\htdocs\test\app\code\core\Mage\Core\Model\Resource\Db\Abstract.php(350): Mage_Core_Model_Resource_Db_Abstract->_getConnection('write')
C:\xampp\htdocs\test\app\code\core\Mage\Core\Model\Resource\Db\Abstract.php(335): Mage_Core_Model_Resource_Db_Abstract->_getWriteAdapter()
C:\xampp\htdocs\test\app\code\core\Mage\Core\Model\Resource\Cache.php(53): Mage_Core_Model_Resource_Db_Abstract->_getReadAdapter()
C:\xampp\htdocs\test\app\code\core\Mage\Core\Model\Cache.php(478): Mage_Core_Model_Resource_Cache->getAllOptions()
C:\xampp\htdocs\test\app\code\core\Mage\Core\Model\Cache.php(520): Mage_Core_Model_Cache->_initOptions()
C:\xampp\htdocs\test\app\code\core\Mage\Core\Model\App.php(1183): Mage_Core_Model_Cache->canUse('config')
C:\xampp\htdocs\test\app\code\core\Mage\Core\Model\Config.php(414): Mage_Core_Model_App->useCache('config')
C:\xampp\htdocs\test\app\code\core\Mage\Core\Model\Config.php(294): Mage_Core_Model_Config->_canUseCacheForInit()
C:\xampp\htdocs\test\app\code\core\Mage\Core\Model\App.php(413): Mage_Core_Model_Config->loadModulesCache()
C:\xampp\htdocs\test\app\code\core\Mage\Core\Model\App.php(343): Mage_Core_Model_App->_initModules()
C:\xampp\htdocs\test\app\Mage.php(684): Mage_Core_Model_App->run(Array)
C:\xampp\htdocs\test\index.php(87): Mage::run('', 'store')
{main}";s:3:"url";s:27:"/test/test/";s:11:"script_name";s:25:"/test/index.php";}

I am unable to find an answer after searching and doing solutions from the internet too.

Can anyone please help me to solve this. Please advice me whether this is because of my old database or any other file issue or else database configuration issue.

Thank You.

3

I suspect the problem you have here is that the configuration is incorrect:

SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: No such host is known. 

The above error is indicating that the hostname for the database server cannot be found (eg you might have been using a hosts file to point to an IP and that host does not really exist, or your server PHP instance is unable to query any DNS servers due to a mis configured DNS.

I suggest you look in app/etc/local.xml for a line similar to this

<host><![CDATA[mydatabaseserver.com]></host>

Change the content of this to the correct server (probably 127.0.0.1 or localhost). You'll likely need to clear the cache in var/cache as well for this to take effect.

  • Thank you quick reply. I checked in both way. but non of them are working. – KNKM May 18 '16 at 10:09
  • @KNKM Ok, what you might want to do then is try in a standard script, echo gethostbyname("the-hostname-you-are-using.com"); does it also generate an error, or does it provide an IP? And also, you might want to debug output the host that it is connecting to in the file (Zend_Db_Adapter_Pdo_Abstract) in case you have more than one database connection defined and a second one is failing. – John Cuthbert May 18 '16 at 10:19

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.