Your browser (Internet Explorer 6) is out of date. It has known security flaws and may not display all features of this and other websites. Learn how to update your browser.
X
Post

“Can’t connect to MySQL server on (*) (13)” Error? Centos or SE Linux? Read on.

I had the most irritating bug in PHP – or so I thought. I simply was unable to connect to the database. I spent the entire weekend recoding and simplifying until I gave up and made a simple connect statement. I kept getting the error message “Can’t connect to MySQL server on (Remote IP) (13)”.

(The “13″ is really confusing and led me down the wrong path. It is actually the result of error code 2003.)

Anyway to save you time, log into your Centos/SE Linux server and type in:

/usr/sbin/setsebool -P httpd_can_network_connect=1

This is basically a setting in SELinux that enables remote connections and is off by default. (Remind me to flay the guy who administers the network). Thanks to the OSCommerce user “ericp502″ who posted the solution.

  • OMG! 2 weeks ive been trying to fix this. i have worked with mysql servers before but never on CentOS. i didn’t even consider that being the problem.

    thank you so much for this post!

    adam

    July 18, 2008

  • THANK YOU SO MUCH for posting this. I was having serious issues with exactly this same problem on RHEL5 with a remote DB. This fixed the problem.

    Ricky

    August 15, 2008