I have two webservers that are essentially clones of each other, both connecting to a remote MySQL server with the same username/password.

The problem is, one of them connects just fine, but the other one gives me this error:

Warning: mysql_connect(): Lost connection to MySQL server at 'reading initial communication packet', system error: 111 in /var/www/includes/classes/DB.php on line 34 Connection has failed

Both servers have the same DB.php file with the same settings. The firewall is allowing all connections to port 3306. I've commented out the default bind-address of I've granted permissions to my user and ran FLUSH PRIVILEGES.

Is there something else I'm missing? Why would one server be able to connect but not the other?

  • What happens when you run telnet failing.server.com 3306, substituting the appropriate hostname? – Andrew M. Dec 6 '10 at 2:54

I was missing something.

iptables was the culprit. There were rules added by the old sysadmin that only allowed the one webserver to connect. Added a rule and off we go!

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.