WordPress: User [...] already has more than 'max_user_connections' active connections

If you have a WordPress site, you may see intermittent “Error establishing a database connection” messages. When debugging this, you can may see the following error message:

User xxx_xxxxxxxx already has more than ‘max_user_connections’ active connections

This article explains what this means and how to fix it.

What does this error mean

In order to prevent a single website from overloading a database server, there is a limit on the number of database connections that can be created for a single account. Attempting to create more database connections than that is not possible, and will result in the error message seen above.

At the time of writing, the maximum number of connections of a single user is 4.

Why do I see this error on my site

In general, there are two reasons why you may see the max_user_connections error on a site:

  • There are too many concurrent requests (visitors) on your site.
  • A page load opens too many database connections to load the page.

The second reason is most common. Most websites never see this issue. If you do, it usually indicates a coding error on your website.

For WordPress, this is usually the result of a plugin or theme creating an excessive number of database connections. We do not know have a list of known plugins and themes that tend to cause this.

How can I fix this issue

You can reduce the number of connections used by your website using one of these methods:

  • Identify the plugin or theme responsible for the excessive database connections, and remove or replace it.
  • Add caching to your site, using plugins like WP Super Cache and W3 Total Cache. Using cache may help avoid some of the database queries.
  • Switch to the default theme (the Twenty-Something theme) to rule out the theme.
  • Install the Query Monitor plugin to gain more insights into database usage.

If you have multiple websites on a single hosting account, you may also want to consider moving some websites to a separate hosting account (you can have up to three hosting accounts). Every hosting account has it’s own database connection limit.

If none of these things help, you can also consider migrating to premium hosting. Premium hosting accounts have much higher limits, including a higher limit on the number of database connections.