I have been recently getting these errors on my server:
mysql_connect() [function.mysql-connect ]: Can't connect to MySQL server on 'xxx.xxx.xxx.xxx' (4)
I don't think this is a credentials issue since the username, password, host IP, and database name are all read from a flat file config and stored in a PHP constant. Plus my error log tells me that the credentials being used are actually the ones in the config.
I tried to google this up and one points me to a
max_connections issue. This site is still in beta and the number of concurrent users does not exceed 10. I looked up the value of
max_connections and it is at 2048
The MySQL version is 5.0.91 and the server is Gentoo Linux (its what the
version_comment says). Socket file is at
/var/run/mysqld/mysqld.sock and port is
What's really bugging me is that this error seems intermittent. I really can't catch it when I am trying to reproduce it. Somebody said from one site that the error index
(4) means interrupted systems calls.
Does this mean that I can dismiss the error as a fault in my web host and not my PHP script?