Jump to content

Recommended Posts

So my site has been working fine until today...I am getting this error when I try to browse to it:

 

Warning: mysql_connect() [function.mysql-connect]: Too many connections in.......blah blach etc etc

 

I am on a 1and1 shared host account if that makes a difference. I have another site on the same server, although using a different database and it works fine still.

 

I tried opening phpMyAdmin through my 1and1 control panel and the control panel is even throwing an error:

 

 

phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in config.inc.php and make sure that they correspond to the information given by the administrator of the MySQL server.

Error

 

MySQL said: Documentation

#1040 - Too many connections

Link to comment
https://forums.phpfreaks.com/topic/125703-too-many-connections/
Share on other sites

Most languages have the option to use 'persistent' connections - this is where a connection to a MySQL server is kept open, even after the script has finished executing. This can be useful to (usually marginally) speed up a script, as the next time the script is executed the MySQL server connection attempt is quickly handed the existing connection. The down side to this is that by holding the connection open, it uses up one of the available connection slots on the MySQL server and so could potentially block another connection attempt (the MySQL server does not have a LRU disconnection policy).

 

As for your "Too many connections" problem, it could be one of three things:

 

1) The server has too many open connections already. A MySQL server can only handle a specific number of open connections before refusing to allow any more, and this limit is shared amongst all users of the server. It's usually set quite high, although it's easily possible for someone to effectively DoS a MySQL server by making lots of connections (but see below)

 

2) Your user account has a limited number of connections allowed per hour - any further connections within that hour would be rejected. This is set on a per-user basis.

 

3) Your user accounts has a limited number of allowable open connections - any further connections would be rejected. This is set on a per-user basis.

 

It's always important to read the error message you get returned on the connection attempt, as in most cases this will pinpoint the exact reason for failure.

 

If your account has a maximum number of connections limit (scenario #3), the error would be:

ERROR 1226 (42000): User 'mysqldba' has exceeded the 'max_user_connections' resource (current value: 1)

 

Where 'mysqldba' would be your username, and the 'current value' is the maximum number of open connections allowed from this user.

 

If you account has a maximum number of connections per hour limit (scenario #2), the error would be:

ERROR 1226 (42000): User 'mysqldba' has exceeded the 'max_connections_per_hour' resource (current value: 1)

 

Where, once again, 'mysqldba' would be your username, and the 'current value' is the maximum number of connections per hour allowed for this user.

 

The error message you got (code 1040) indicates that the entire MySQL server has run out of connection slots - this is the DoS scenario I mention above.

 

What can you do about it? From what you've said, you don't have superuser privileges on this server, so nothing, apart from complain to the SysAdmin responsible for that server. They might increase the maximum number of connections allowed, which could solve the problem short-term, but if someone else using the server is creating a stupid number of database connections the slots would just fill up again. What they probably should do is to also enforce a per-user maximum open connection limit as well - this would stop the heavy users clogging up the server. In a shared-server situation like yours, this would make the most sense - 'power users' would/should have their own server, or could/should pay to increase their maximum open connections.

Link to comment
https://forums.phpfreaks.com/topic/125703-too-many-connections/#findComment-651134
Share on other sites

  • 1 year later...
  • 3 years later...

I am having this issue on and off for about a year now .. it seems that they would like me to purchase "dedicated server" hosting, because they only solve this problem for a period of time.

My forum is nowhere near that busy or producing that kind of money.

In retrospect, I am regretting for purchasing 1&1 hosting. After 7 yaers of being their customer one would think they would appreciate it, but they just don't care.

 

1040toomanyconnections.jpg

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.