Sebastian
Sebastian

Reputation: 3628

Intermittent "Error establishing database connection" on WordPress

I'm getting the above error maybe 1 in 10 times I load a page (both on the website and control panel).

I've also noticed that when I log into phpMyAdmin I quite often get this error:

#1203 - User xxx already has more than 'max_user_connections' active connections

It feels like a memory/caching problem, but I'm not sure what the fix is.

I've tried decreasing the memory allowance for this WordPress instance as well as deactivating plugins and deleting other WordPress installations (though I can't delete the database fields because of the aforementioned phpMyAdmin problem).

Any idea?

Upvotes: 0

Views: 2501

Answers (2)

Mounika Nadukuru
Mounika Nadukuru

Reputation: 1

My problem has been resolved.

On investigation, it could be seen that the website is loading database connection error when the database user is exceeding the maximum allowed connections per user which is 10.

In our shared platform, they allow a maximum of 10 concurrent connections to a database, which is ideal in the shared platform and unfortunately, it is not possible to increase this limit.

So, I have upgraded my hosting plan. It’s working fine now.

Upvotes: 0

Cal Evans
Cal Evans

Reputation: 687

This is not a memory issue, it's a connections issue with MySQL.

The MySQL manual covers it here:

http://dev.mysql.com/doc/refman/5.5/en/too-many-connections.html

Basically, you have a limited number of concurrent connections and you are exceeding that limit. The reason it is intermittant is that as PHP finishes rendering a page, it tears down the connections and it's available for the next person.

If you are not on shared hosting, the answer is to open your my.cnf file, adjust that value, and restart MySQL. if you are on shared hosting, you will have to talk to their support system and see if they will/can raise it.

HTH,

=C=

Upvotes: 3

Related Questions