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

I have an apache web server (Red Hat Enterprise Linux Server release 5.5 (Tikanga)) running PHP 5.3.2. I am trying to make a connection with php to a new Ubuntu 10.04 64 bit server running mysql server. Heres a run down of the settings in place.

  • mysql server version 5.1
  • There are no firewall rules restricting connections between these two machines. neither in our hardware firewall or in iptables.
  • /etc/mysql/my.cnf has the bind-address set to the machine's ip.
  • skip-networking is commented out, ie disabled.
  • mysql is running and on the standard port 3306

the following is my php connection script:


$nl = "<br>";


$conn = mysql_connect($host, $user, $pass);

if (!$conn){
        die('Could not connect: ' . mysql_error() . $nl);
else {
        echo "connected!";



attempting to execute the php script in a browser hosted on the apache server only yields: "Could not connect: Can't connect to MySQL server on '555.555.55.55' (4)"

any suggestions? Thanks.

share|improve this question

Test 1 has got to be:

apachebox% telnet mysqlbox 3306

if that doesn't connect, you have a problem which must be sorted before anything else will work.

share|improve this answer
+1 for this answer, the first test is to check for connectivity! – Oneiroi Nov 12 '10 at 10:31
If this works, you should also try 'mysql -u some_user -h 555.555.55.55 -p' before trying to connect from PHP – Saurabh Barjatiya Nov 12 '10 at 12:51
ah, sorry, this follow up answer was posted on mysql -u root -p -h <ubuntu-server-ip> from redhat yields: "ERROR 2003 (HY000): Can't connect to MySQL server on '555.555.55.55' (110)" – ifeltalive Nov 12 '10 at 15:04
Trying 555.555.55.55... telnet: connect to address 555.555.55.55: Connection refused telnet: Unable to connect to remote host: Connection refused – ifeltalive Nov 12 '10 at 15:58

If it's a timeout, install tshark. (Your package manager should have a current version)

On the client and server: (add -i <adaptor> if it's not eth0 that's being used)

tshark port 3306

Try the connection again and watch both sessions to see where the packets are being dropped. This will narrow down where to look, to start with.

share|improve this answer
tcpdump port 3306 will also do the job on RHEL and derived OS's – Oneiroi Nov 12 '10 at 10:29
ive never used this one. thanks for the tip. – ifeltalive Nov 12 '10 at 18:09

SELinux? Maybe it is enabled and not configured.

Can you connect to your Mysql server from another client within LAN?

share|improve this answer
If this is the case check /var/log/audit/audit.log for denied messages, and getenforce to check if SELinux is running. – Oneiroi Nov 12 '10 at 10:30

We changed the ip of the machine to a different ip range within our institution. from a private range to a public ip. it now connects. We're now investigating this private range. Thanks for everyones help!

share|improve this answer

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.