Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Here's an interesting one that does not seem to fall into any of the mysql connection issues I've read about or searched for: On an Ubuntu 12.04 box I had some system updates waiting to install, and I took care of that this evening. After the install, I started seeing some errors in my syslog complaining about a particular php script that could no longer connect to the mysql instance on the box. Here is the specific error:

PHP Warning:  mysql_connect(): Can't connect to MySQL server on '' (4) 

Now, the server's IP address is, and I've checked to make sure that I have mysql listening on so that I can connect using either "localhost" or "".

Here's where things get odd: From the local machine, if I try the following:

mysql -uroot -p -h192.168.0.40

I get this error:

ERROR 2003 (HY000): Can't connect to MySQL server on '' (110)

I've checked, and error 110 indicates an OS timeout, and error 2003 is the mysql generic "can't connect" error. This indicates that it is not permissions with the user.

However, if I do the same thing from a remote machine (say, from, I log right in with no problems.

Futher, other scripts on the local machine that connect to mysql using "localhost" for the host rather than "" connect with no problems. Also, I can connect via the mysql socket with no problems both from the command line and php scripts.

So, this feels like a networking issue of some kind on the local box, but there are no iptables rules on this box (it is firewalled externally) and I can't figure out what else may be causing this.

This problematic script worked perfectly prior to the latest system update.

For now, I'll simply change the script to connect via localhost, but I'd really like to know why it broke for 2 reasons:

  1. There may be other scripts that connect using that don't run very often which are now broken. Auditing them all will take more time than I feel like devoting at the moment.

  2. I'm curious, and want to know why it broke so I can fix it correctly.

Any help?

share|improve this question

migrated from Oct 31 '12 at 2:03

This question came from our site for professional and enthusiast programmers.

Maybe better for serverfault – Mike Brant Oct 29 '12 at 6:26
I am facing same issue, how did you fix it ? – user1191081 Dec 4 '13 at 7:13

If you really mean to access the server remotely, then open up the proper firewall port (default 3306).

share|improve this answer

Make sure MySQL user has the permission to connect from

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.