MySQL / Editorial solution guide

Diagnose exhausted MySQL connection capacity

Distinguish server connection exhaustion from account limits and application pool saturation before changing capacity.

About 3 min readContent reviewed

Read-only knowledge base · No public comments

Recognize the symptoms

The application reports Too many connections, an account connection limit, or a timeout waiting for a pooled connection. These messages can arise at different boundaries. Record the exact error, operation, time, and endpoint; a pool timeout by itself does not prove that the server rejected a new connection.

Understand the likely causes

  • Connections may remain checked out too long, multiply across application instances, or accumulate during slow transactions. A spike or retry storm can also exhaust capacity. Server-wide connection limits, account-specific limits, and an application pool limit are separate controls; memory, file descriptors, and workload capacity also matter.

Identify the exhausted boundary

Record the server identity, application deployment and instance count, pool configuration, error code, and whether the failed request reached MySQL. Compare the time of failures with connection and pool metrics. For a server-reported limit, an authorized administrator can inspect connection counts, relevant configuration, and the change in Connection_errors_max_connections. Counters are cumulative, so compare timestamps rather than interpreting one value as a rate.

For account-specific failures, compare the actual authenticated account and applicable resource limits. A pool acquisition timeout can instead occur when all pool slots are checked out even while the server has spare capacity. Redact connection strings, credentials, and sensitive query text from shared evidence.

Trace connection ownership and lifetime

Use permitted process-list or monitoring evidence to classify application connections by account, host, state, and age. Visibility depends on privileges; a restricted session may show only its own threads. Correlate this with pool checkout duration, active requests, transaction duration, slow operations, and recent scaling or retry changes. A sleeping connection can be a normal idle pooled connection, so do not infer a leak from that state alone.

In a disposable load test, verify that every success, error, and cancellation path returns the connection to the pool and ends its transaction appropriately. Compare the maximum aggregate pool demand across instances with the deployment’s available connection and resource budget.

Apply a bounded correction

Fix the evidenced leak, excessive checkout duration, blocking operation, or retry behavior first where applicable. Adjust pool sizing or server capacity only through the documented change process and after checking total concurrency and resource headroom. Do not terminate arbitrary sessions or raise a global limit blindly: either action can disrupt work or move the bottleneck to memory and processing capacity. Preserve a way for authorized administrators to diagnose the server according to its configured interfaces and privileges.

Verify recovery and prevent recurrence

From the original client context, repeat a permitted application operation and observe pool acquisition latency, checked-out connections, server connection counts, and rejection counters over the same time window. Exercise a representative load and an error path in a safe environment; verify that connections return and transactions finish. Alert on sustained saturation and rising rejection rates, document pool budgets for all instances, and revisit them when the deployment scales.

Verify the fix

The original application operation succeeds and the relevant pool and server saturation indicators recover over an observed interval.

A controlled error-path test returns its connection and ends the transaction according to the application contract.

Keep it from recurring

  • Set and monitor a connection budget across all application instances and administrative needs.
  • Test pool checkout, cancellation, transaction cleanup, and bounded retry behavior under representative load.

Official references