InMotion Hosting Support Center

Too many connections error on quite site

Category: Drupal 7

n/a Points
2015-04-24 1:44 am EST

Hits: 3,368
A user today reported receiving error - PDOException: SQLSTATE[08004] [1040] Too many connections in lock_may_be_available().
According to google analytics our site is fairly quiet. How do i fix this or is a shared hosting issue?

You must login before you can ask a follow up question.

You must login before you can submit an answer.



42,973 Points
2015-04-24 10:14 am EST

Sorry to hear about the connections issue. I'm assuming that you're having this issue with a Drupal site since you placed the question in the Drupal category. The error indicates that Drupal is making too many database connections. This is due to the setting in your local PHP.INI file. You can modify your PHP.INI file and then limit the connections - currently it's set to unlimited. Try making the max connections set to "100". You an find suggestions on this issue in the Drupal Support forum. This issue has been discussed many times on their site. I hope this helps to answer your question, please let us know if you require any further assistance.

Kindest regards,
Arnel C.

You must login before you can post a comment about this answer.

Thanks Arnel and I had already trawled the drupal community before coming to you including that link and others.

I wonder could you provide a little more detail please on what you are suggesting. Other sites suggest my.cnf as the fix or changes variables using phpadmin.

I have gone into Phpadmin which is one of the suggestions inmotion make on their site and the variables on my site are as follows:
max connections = 750
max user connections = 20

I have no ability to change these and no knowledge of whether this is the problem or whether it was an overflow from someone else's site usage chewing up general resources.

When you say
"You can modify your PHP.INI file and then limit the connections - currently it's set to unlimited"
Would it be possible please for you to expand on what connections you are suggesting I limit. if it is max connections, then at the moment thaey appear to be set to 750.

It is not clear to me how limiting connections further helps me with an error that states not enough connections available. It is counter-intuitive to me as I would expect that the fix would be to increase, not decrease connections.

Thanks for your time in looking at this.
13 Points
2015-04-24 7:07 pm EST
Hello Petert,

From what I understand of it, the PHPINFO.PHP shows the settings that you're using per the PHP.INI file. The error that's occurring is specific to your account. As per the Drupal support forum, it's happened even in cases of fresh installs. For some reason Drupal is opening multiple connections to the database and NOT closing them. This results in the error. If you're on a shared server, then this becomes a problem as the MySQL server is a shared resource. Limiting the number of connections that Drupal can make is one way to keep that issue from happening. 750 connections shouldn't be necessary from a single Drupal installation. These connections aren't made to be kept open, they typically are "open", "write/read" , "close" , so limiting them will be key, especially in a shared environment. The alternative would be to upgrade to a dedicated server where ALL of the resources belong to you.

I hope this helps to answer your question, please let us know if you require any further assistance.

Arnel C.
42,973 Points
2015-04-24 10:06 pm EST

2015-04-26 9:39 pm EST
Thanks again Arnel
I’m sorry but I still do not understand the idea that reducing the number of connections will result in not receiving a max connections exceeded error.

The current max_connections value of 750 is a default value applied by the setup of drupal either natively or by the inmotion techs (I have not touched it.)

You say that reducing this will fix the max connections error problem but that logic indicates that it would not solve my problem, but it would solve the problem of other users on my system getting the same error (in the event where my high setting might have hogged resources and caused problems for *them*.)

You imply that my issue is potentially caused not by my system, but by the resource usage of other sites that are sharing my hosted resource.

That is actually what I am trying to determine. Is this error a one-off caused by someone else’s unthrottled usage affecting me or is it an error with my own site config. I don’t see how throttling my own usage below 750 helps me, though I can see how it could though help others.

I am beginning to suspect that the relatively high value of 750 has been set by inmotion techs for some reason, and if it is present across all sites sharing the resource, then this could be what is causing the issue. Either that or someone else has an unlimited setting and that is causing them to hog resources.

That would indicate that the fix is for **everyone** to reduce their setting. Me alone reducing my setting isn’t going to help my situation (though it might help others sharing my resources.)
From what I have googled by the way the usual response is to increase (not decrease ) max_connections and the usual place to do it is /etc/my.cnf using this syntax:

That said 750 is already a high setting (but I reiterate – I don’t see how reducing it can help me, though it may help others.)

Another smoking gun is apparently when search engines visit sites, and the fix to that is to add the 'Crawl-delay' parameter in the robots.txt or to set it to a higher number of seconds.
Mine was 10 seconds and I have moved it to 15.

With all of the above in mind I am beginning to suspect the issue is not with my site, but with other sites using the shared resource one or more of which chewed it up.
Thanks again for your response

You must login before you can post a comment about this answer.

Like this Question?

Forum Login

You are NOT logged in. You can still browse our Support Center.

To participate within our Community Support Forum:

Need more Help?


Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail:
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!