MySQL Too Many Connections: Find the Client Holding Them Open
Compare open and active connections against max_connections, then use WatchLog to find the client keeping MySQL or MariaDB slots occupied.
A MySQL server can run out of connection slots even when few queries are running. Before raising max_connections, check whether the slots are busy doing work or sitting in an application’s connection pool. Those two cases point to different fixes.
Compare open connections with active sessions
Open the MySQL or MariaDB instance in WatchLog and check Right now and the Connections view. Compare the total with max_connections, then split running from sleeping sessions. An asleep session still takes a slot. In WatchLog’s illustrated example, 137 of 151 slots are used, and report-worker holds 130 asleep. The mean query time is only 4 ms and no sessions are waiting on a lock in that snapshot.

Find the client keeping the slots occupied
Open the workload or service named by the connection finding, if WatchLog can attribute it. Check its total connections, sleeping count and how long they have been idle. Compare the session or account view with the workload name. A shared login, proxy or unmapped address can make that check inconclusive; do not identify a service by database username alone. If running sessions and query latency rise together, look at what those sessions are waiting on instead.
Compare occupancy with deployments and pool settings
Check whether idle connections grew after a deploy, a scale-out or an increase in the per-process pool maximum. A pool may intentionally keep spare connections. Compare the expected total across replicas and worker processes with what the server shows. Where the application exposes them, line up idle, in-use and waiting-for-a-connection counts with the database charts. Sustained occupancy after traffic falls is a reason to check for oversized pools or connections not being returned. One screenshot does not prove a leak.
Know what the collector can see
WatchLog connects using a read-only monitoring user. Its setup guide covers MySQL 8+, MariaDB 10.6+ and Percona Server. On MariaDB, if the statement waits or statement-sender view is missing, check the page’s setup notice and the performance_schema and statement consumer settings. Basic connection data remains useful without those per-statement views. Keep connection attribution separate from proving which service sent a particular SQL statement.
See WatchLog’s MySQL and MariaDB monitoring example and the read-only setup guide. If you already track how long your application waits for a slot, put that metric on a WatchLog dashboard alongside the server’s connections.