I am getting the following error:
mysql_connect(): Too many connections
It has completely shut down my site, which has been running seamlessly for several years.
Note: I have shared hosting with GoDaddy.
How do I fix this?
ALSO: is there a way to close all connections and restart when on a shared hosting plan?
Most probably, you have been a subject of a
DDoSattack.People on this forum complain on exactly same thing with exactly same provider.
The answer is this:
A possible workaround can be this: if your connection fails with
mysql_connect(): Too many connections, you don’t quit, but insteadsleep()for half a second and try to connect again, and exit only when10attempts fail.It’s not a solution, it’s a workaround.
This of course will delay your page loading, but it’s better than an ugly
too many connectionsmessage.You also can come with a some kind of a method which tells bots and browsers apart.
Like, set a salted
SHA1cookie, redirect to the same page and then check that cookie and connect toMySQLonly if the user agent had passed the test.