Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Databases and Redis

MySQL says the user already has more than max_user_connections active connections

ErrorERROR 1203 (42000): User app already has more than 'max_user_connections' active connections

Short answer

Error 1203 means one account is at its own connection ceiling, not the server's. The ceiling is the account's MAX_USER_CONNECTIONS value, or the global max_user_connections variable when the account value is 0. Find the limit that applies, then raise it or close the connections your application leaves open.

  • Applies to MySQL 8.0, MySQL 8.4
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Read the two numbers that decide the limit: the global variable and the account's own value (0 means the global one applies), then list the live connections and count those of that account.

    SHOW VARIABLES LIKE 'max_user_connections';
    SELECT User, Host, max_user_connections FROM mysql.user WHERE User = 'app';
    SHOW PROCESSLIST;
  2. 2Match what you see, then jump to its fix

    1. 1mysql.user shows a small non-zero max_user_connections for that accountThe account has a low MAX_USER_CONNECTIONS limitFix
    2. 2The account row shows 0 and SHOW VARIABLES gives a small number for max_user_connectionsThe account value is 0 and the global max_user_connections is smallFix
    3. 3The account is exactly at its limit and the error appears only now and then, right after a reconnectA disconnect and an immediate connect raceFix

What does the error look like?

  • ERROR 1203 (42000): User app already has more than 'max_user_connections' active connections
  • ER_TOO_MANY_USER_CONNECTIONS

Cause 1 of 3

The account has a low MAX_USER_CONNECTIONS limit

1Check

A non-zero account value is the cap for that account, whatever the global variable says.

SELECT User, Host, max_user_connections FROM mysql.user WHERE User = 'app';

2Fix

Raise the account limit to what the application really needs, or set it to 0 so the global value applies.

ALTER USER 'app'@'%' WITH MAX_USER_CONNECTIONS 20;

3Verify

Reconnect as that account and run the workload that failed.

SELECT User, Host, max_user_connections FROM mysql.user WHERE User = 'app';

Confirmed by dev.mysql.com

Did this fix it?

Cause 2 of 3

The account value is 0 and the global max_user_connections is small

1Check

When an account value is 0, the global max_user_connections decides. If that is 0 too, there is no limit for the account.

SHOW VARIABLES LIKE 'max_user_connections';

2Fix

Give the busy account its own explicit value. A non-zero account value replaces the global one for that account only, so other accounts keep their limit.

ALTER USER 'app'@'%' WITH MAX_USER_CONNECTIONS 50;

3Verify

Read the account row back.

SELECT User, Host, max_user_connections FROM mysql.user WHERE User = 'app';

Confirmed by dev.mysql.com

Did this fix it?

Cause 3 of 3

A disconnect and an immediate connect race

1Check

The manual describes an edge case: when an account has its maximum connections open, a disconnect followed quickly by a connect can fail if the server has not finished processing the disconnect.

SHOW PROCESSLIST;

2Fix

Leave headroom. Set the account limit above the largest pool size your application runs, and add a short retry in the client for the connect call.

ALTER USER 'app'@'%' WITH MAX_USER_CONNECTIONS 25;

3Verify

Restart the application several times and confirm the error no longer appears.

SHOW PROCESSLIST;

Confirmed by dev.mysql.com

Did this fix it?

How do I stop it coming back?

  • Set the pool size of each application below the account's limit, counting every instance.
  • Give each application its own MySQL account, so a limit on one cannot starve another.
  • Keep a record of which accounts carry a MAX_USER_CONNECTIONS value, so a limit is never a surprise.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.