Database blocked because of many connection errors

10 posts by 5 authors in: Forums > CMS Builder
Last Post: November 11, 2015   (RSS)

By ennisoft - October 1, 2015

Hi,

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.

Thanks,

Ross

Hey Ross,

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:

https://www.interactivetools.com/support/email_support_form.php

and we'll try take a closer look at the issue.

Cheers,

Greg

Greg Thomas







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.

J.

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...

Ross

By Dave - October 14, 2015

Hi Ross, 

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!

Dave Edis - Senior Developer
interactivetools.com

Hi Dave,

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.

and

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?

Thanks,

Ross

By Dave - October 19, 2015

HI Ross, 

>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!

Dave Edis - Senior Developer
interactivetools.com

Thanks Dave, that's pretty much the direction I was heading with this. Thanks for the great support as always!

Ross

Hi Ross, I experienced this same exact problem a few years ago.

It all boiled down to getting a better hosting package.

Shared hosting for websites with lots of traffic just does not work out.

I switched to a Dedicated Server and all is fine after that switch.

Arif Khayam.