About Me: Jawaad Mahmood: 30, Muslim, Canadian, freelance, doing consulting in Tokyo, Japan.

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

May 12, 2008

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.

Comments (2)

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

  1. adam says:

    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!

  2. Ricky says:

    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.


Archives 
August 2010 July 2010 May 2010 April 2010 March 2010 February 2010 January 2010 December 2009 November 2009 October 2009 August 2009 July 2009 June 2009 May 2009 April 2009 March 2009 February 2009 January 2009 December 2008 November 2008 August 2008 July 2008 June 2008 May 2008 April 2008 March 2008 February 2008 January 2008 December 2007 November 2007 October 2007 July 2007 June 2007 May 2007 April 2007 March 2007 February 2007 January 2007 December 2006 November 2006 October 2006 September 2006 August 2006 July 2006 June 2006 May 2006 April 2006 March 2006 February 2006 January 2006 December 2005 November 2005 February 2005 December 2004 November 2004 October 2004 September 2004

Creative Commons License
All text and images under 1024 x 768 pixels on this site are licensed under a Creative Commons Attribution 3.0 Unported License.
I require a link back to the original page of the article/image. If the image/article
is not public (IE: It is not present in an article on the blog), you may not reproduce it without permission.