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 see | What it means |
|---|---|
Most connections in Sleep from one client | A pool sized larger than the server, or connections that are never closed. |
| Most connections running, all on one table | They wait behind a lock: see lock wait timeout. More connections will not help. |
| Connections climb in steps after a deploy | A new release with a larger pool, or a leak. |
The fix, in order
- Free the slots that do nothing. End the sleeping connections of the account that holds the most; the application reconnects.
- Find what is stuck. When the connections are busy, they wait for something. Fix that and they return to the pool.
- Size the pools. The sum of every application's pool, times its instances, must fit under
max_connections. - Limit one account.
max_user_connectionskeeps one application from taking all the slots. - Close idle connections.
wait_timeoutends connections idle for longer, 8 hours by default. - Raise the limit last. Each connection takes memory for its buffers and threads. Raise
max_connectionswhen 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:
| Detector | When it fires |
|---|---|
| Connections running out | Watch 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 surge | Active sessions at 3 times the usual for that time. |
| Blocking | Sessions 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
- MySQL 8.0 Reference Manual: Too many connections, max_connections, Administrative connection interface, wait_timeout