Can't Connect To Local Mysql Using IP Address, but CAN connect from remote server
Posted
by
user1782041
on Server Fault
See other posts from Server Fault
or by user1782041
Published on 2012-10-29T05:53:39Z
Indexed on
2012/10/31
5:07 UTC
Read the original article
Hit count: 516
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 '192.168.0.40' (4)
Now, the server's IP address is 192.168.0.40, and I've checked to make sure that I have mysql listening on 0.0.0.0 so that I can connect using either "localhost" or "192.168.0.40".
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 '192.168.0.40' (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 192.168.0.30), 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 "192.168.0.40" 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:
There may be other scripts that connect using 192.168.0.40 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.
I'm curious, and want to know why it broke so I can fix it correctly.
Any help?
© Server Fault or respective owner