Search code examples
phpmysqlzend-frameworkzend-dbzend-db-table

Zend Framework error [database connection]


Today trying to run my project coded under Zend Framework, and connected to a remote database, i got those 2 errors:

PDOException: SQLSTATE[HY000] [2002] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in C:\wamp\www\trunk\library\Zend\Db\Adapter\Pdo\Abstract.php on line 129

Zend_Db_Adapter_Exception: SQLSTATE[HY000] [2002] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in C:\wamp\www\trunk\library\Zend\Db\Adapter\Pdo\Abstract.php on line 144

Before it was working normally, and i don't know what going on with it today. It seems it's a connection problem to the database but the question, where the problem come from, from the database server, or my project and where excatly. It's the first time, i got this error, and i really don't know what that mean.


Solution

  • It sounds like a network problem to me, try a telnet from the app server:

    telnet <remote db name/IP> 3306
    

    If that fails, you have a network/firewall problem. Or the DB is is not listening on that port or on the network entirely. Do a netstat on the remote DB to confirm: Linux

    netstat -an | grep LISTENING
    

    Or windows

    netstat -an | find "LISTENING"
    

    You should see :3306 if it's listening on the default port.