Last updated: August 29, 2026.
The MySQL error “Too many connections” means that every connection available to ordinary client accounts is in use. Before raising max_connections, determine whether traffic increased, the application leaks connections, idle sessions accumulate, or slow work keeps sessions occupied.
Measure current and peak usage
SHOW GLOBAL STATUS LIKE 'Threads_connected';
SHOW GLOBAL STATUS LIKE 'Max_used_connections';
SHOW GLOBAL VARIABLES LIKE 'max_connections';
SHOW GLOBAL STATUS LIKE 'Connection_errors_max_connections';Threads_connected is the current count. Max_used_connections is the peak since startup, and Connection_errors_max_connections counts connection attempts rejected at the limit. Monitor these values over time instead of relying on one reading after the incident.
Find who is holding the connections
SELECT USER,
SUBSTRING_INDEX(HOST, ':', 1) AS ClientHost,
COMMAND,
COUNT(*) AS ConnectionCount,
MAX(TIME) AS LongestSeconds
FROM information_schema.PROCESSLIST
GROUP BY USER, SUBSTRING_INDEX(HOST, ':', 1), COMMAND
ORDER BY ConnectionCount DESC;
SHOW FULL PROCESSLIST;Many long-lived Sleep rows usually point to an oversized pool, missing connection cleanup, or an excessive idle timeout. Many active rows running the same statement suggest slow queries, blocking, or a workload spike. Do not terminate sessions blindly when they may own open transactions.
Check the application pool
- Use a bounded pool and release connections reliably after errors.
- Calculate the total across every web worker, job worker, and application instance.
- Do not hold a connection while calling a slow external service.
- Set a connection-acquisition timeout so requests fail predictably rather than accumulating.
- Review the pool’s idle lifetime together with MySQL’s
wait_timeout.
Raise the limit carefully
Every connection uses memory, and active queries can allocate additional buffers. Increase the limit only after checking available memory and correcting leaks or slow queries.
-- Runtime change; persist the final setting through server configuration.
SET GLOBAL max_connections = 300;
SHOW GLOBAL VARIABLES LIKE 'max_connections';MySQL reserves an extra connection for an administrator with the CONNECTION_ADMIN privilege. Do not grant that privilege to the normal application account; it preserves a diagnostic path when ordinary connections are exhausted.
Quick recovery checklist
- Capture process-list and connection metrics.
- Reduce unnecessary application concurrency.
- Fix leaks, slow queries, or long transactions.
- Adjust pool sizes and server capacity together.
- Monitor rejected connections, memory, and query latency.
Continue with authentication plugin errors and MySQL database size queries.
Reference: MySQL 8.4 Too many connections guidance.