Database blocked because of many connection errors
On a school's website running CMSB, every couple of weeks the website goes down with the following error message:
We were unable to connect to the database, possibly because:
Your database settings are incorrect (check in /data/settings.dat.php)
Your database server is down or overloaded (check with your host)
The database error given was:
Host '<Control Panel Name>' is blocked because of many connection errors;
unblock with 'mysqladmin flush-hosts'
Obviously the hosting company says that it's the code that is the issue rather than their servers. Naturally I need to be sure this is not the case. What should I be looking for in the way of error logs? Any other pointers you can give?
The site was stable for a long period before this started.
CMS Builder doesn't change the MySQL settings for the number of simultaneous connections, so this is most likely an issue with your hosting. Could you try contacting your hosting company saying you're getting this error:
The database error given was:Host '<Control Panel Name>' is blocked because of many connection errors;unblock with 'mysqladmin flush-hosts'
and ask them how you can increase the number of connections allowed to MySQL? Don't mention the PHP file that's caused it, as this isn't relevant.
If they still say it's related to CMS Builder, you can fill in a second level support request here:
and we'll try take a closer look at the issue.
PHP Programmer - interactivetools.com
FWIW we had a similar issue crop up out of the blue last week. The became unusable as a result.
The hosting company did not allow us to run a flush-hosts command (blocked via limited permissions). Eventually they ran the flush and all was well.
I suspect that they may also have increased the connections allowance but I can't prove that.
Thanks for this guys, but it still seems to be beyond the abilities of the hosting team to raise the connections as required.
What does the number of connections depend on, is it determined by the code or the number of visitors to the site? And where are the errors likely to be generated (I'm assuming time outs from the server)?
The host support have asked me how many connections I expect to the server - sound like a "How long is a piece of string" question to me...
Googling for "is blocked because of many connection errors" shows some related info:
It's nothing to do with regular mysql connections, it's caused by "connection requests from a host are interrupted without a successful connection".
It's usually caused by exploit scanners, network problems at the host, websites getting overloaded and timing out after waiting a long time to connect to MySQL, etc.
But none of those things should cause you to get locked out of your own website, and it's definitely something your host should be able to resolve.
Can you ask your host if they can review the mysql logs and see if they can confirm where the interrupted mysql connections are originating from (IP, mysql username, etc)? And if they can update their configuration to prevent mysql from blocking known good hosts like your website?
Let us know what they say, and good luck!
Thanks for the additional info - I'm not getting anywhere with the hosting company, here's a selection of their replies:
We made standard optimization for mysql configurations within your account. We checked and monitored the domain till time and it is loading fine with us now.
You are under "share hosting plan" and other customers use the same server. We have this issue only with your website - "blocked because of many connection errors" . Unfortunately we can not "increase max_connect_errors to 1000000 or setup a cron job to run "FLUSH HOSTS"" as it is very un-secure, and it take effect with our other customers. I've investigated it once again, I added more permission to your database user. Hopefully it will help at this stage.
The problem recurs daily now. Is there any chance that the code is the problem?
>The problem recurs daily now. Is there any chance that the code is the problem?
We've got literally thousands and thousands of installs running and that error is very rare (I haven't seen it in over a year or more), so it's likely something specific to the server configuration or other network activity at the hosting company.
I'm not sure how I could even recreate that error. I believe it's caused by an aborted mysql_connect() call or a abruptly terminated mysql connection (which shouldn't be possible to do with normal PHP code).
And, unfortunately, I can't investigate further as the site is down.
Once more thing you could try is to install the MySQL console: https://www.interactivetools.com/add-ons/mysql-console/ and run this command to see if it shows what connections or requests are open:
SHOW FULL PROCESSLIST
Failing that, how much is the client paying for hosting? Often cheap shared hosting isn't worth it (<$20/mo). You could suggest they upgrade to VPS or Dedicated server: https://uk.godaddy.com/pro/managed-vps
Hope that helps!
Thanks Dave, that's pretty much the direction I was heading with this. Thanks for the great support as always!