MySQL problems

MySQL Too Many Connections: Who Holds Them, and the Fix

2 December 2026

ERROR 1040 (HY000): Too many connections means Threads_connected reached max_connections, 151 by default. Raising the limit is the last step, not the first: most full servers are full of sleeping connections that one application opened and never gave back.

Getting in when the server is full

MySQL keeps one extra connection for an account with CONNECTION_ADMIN (or SUPER). From 8.0.14 a separate administrative port does the same with its own limit; set admin_address before you need it.

Who holds the connections

SELECT user,
       SUBSTRING_INDEX(host, ':', 1) AS client,
       command,
       COUNT(*)                      AS connections,
       MAX(time)                     AS longest_seconds
FROM   information_schema.processlist
GROUP  BY user, client, command
ORDER  BY connections DESC;

SHOW GLOBAL STATUS WHERE Variable_name IN
  ('Threads_connected', 'Threads_running',
   'Max_used_connections', 'Connection_errors_max_connections');
What you seeWhat it means
Most connections in Sleep from one clientA pool sized larger than the server, or connections that are never closed.
Most connections running, all on one tableThey wait behind a lock: see lock wait timeout. More connections will not help.
Connections climb in steps after a deployA new release with a larger pool, or a leak.

The fix, in order

  1. Free the slots that do nothing. End the sleeping connections of the account that holds the most; the application reconnects.
  2. Find what is stuck. When the connections are busy, they wait for something. Fix that and they return to the pool.
  3. Size the pools. The sum of every application's pool, times its instances, must fit under max_connections.
  4. Limit one account. max_user_connections keeps one application from taking all the slots.
  5. Close idle connections. wait_timeout ends connections idle for longer, 8 hours by default.
  6. Raise the limit last. Each connection takes memory for its buffers and threads. Raise max_connections when the server has the memory and the workload really needs it.

See it coming

Radar Engine, the detection layer of dbCove, warns before the first refused login, with no agent on the server:

DetectorWhen it fires
Connections running outWatch at 80% of max_connections for 3 minutes and above the usual. Warning at 90%, or at 80% and on course to reach 100% within 30 minutes, or any refused login in the last 10 minutes. Critical at 97%.
Load surgeActive sessions at 3 times the usual for that time.
BlockingSessions queue behind one head, the usual reason a pool runs dry.

The finding names the account and client host that hold the most connections, how many of them sleep, and the minutes left until the server is full. dbCove AI answers who opened them and since when.

Questions

How do I fix "Too many connections" in MySQL?
Log in with an account that has CONNECTION_ADMIN, find the account and host that hold the most connections in information_schema.processlist, end the idle ones, and fix the pool or leak behind them. Raise max_connections only when the memory allows it.

What is the default max_connections in MySQL?
151.

How do I see the highest number of connections MySQL reached?
Max_used_connections in SHOW GLOBAL STATUS, with Max_used_connections_time for when.

Related problems

Sources