"Too many connections" means MySQL hit its connection limit and is refusing new ones — so your site or server can't reach the database. Here's the quick fix, the real fix, and how to find what's actually leaking connections.
Quick answer
"Too many connections" means MySQL reached its max_connections limit (151 by default). For a quick recovery, restart the app or kill sleeping connections; for the real fix, find what is leaking them with SHOW PROCESSLIST, lower wait_timeout and use persistent connection pools. Raise max_connections only if the server has RAM to spare.
Why it happens
MySQL allows a fixed number of simultaneous connections (max_connections, often 151 by default). When apps open connections faster than they close them — or leak them — the limit fills and everything new is denied.
See the current state
SHOW VARIABLES LIKE 'max_connections';
SHOW STATUS LIKE 'Threads_connected';
SHOW PROCESSLIST; -- what's actually connectedQuick fix: raise the limit (live)
You can raise it without a restart to get back online:
SET GLOBAL max_connections = 300;Make it permanent in my.cnf so it survives a restart:
[mysqld]
max_connections = 300If connections keep piling up, an app is leaking them or queries are running too long. More connections + more RAM use can crash the server. Fix the leak, don't just raise the ceiling forever.
Fix the root cause
- Use connection pooling / persistent connections correctly in your app.
- Kill long-running/stuck queries (find them in
SHOW PROCESSLIST). - Lower per-connection memory if you raise the limit a lot.
- Make sure one buggy plugin/script isn't opening connections in a loop.
Raise max_connections to get back online, then find what's leaking connections — the limit is a symptom, not the disease.
How to find exactly what's eating connections
SHOW PROCESSLIST lists every open connection with its source host and current query — group by host/user (a query against information_schema.processlist grouped by user and host works well) to spot one app or IP opening far more than the others. A WordPress site with a runaway plugin, a bot/crawler hammering a script, or a game panel with a broken database pool are the usual suspects.
A safe max_connections value
Each connection reserves memory (thread stack plus buffers), so raising the limit on a small VPS can itself cause an out-of-memory crash. Rough guide: leave enough RAM headroom that max_connections × per-connection memory never approaches total system RAM — on a small server, tune the workload down rather than pushing the limit past a few hundred.
Related errors
If the database service itself won't start at all, see fixing MySQL/MariaDB won't start. WordPress sites hitting this from the same root cause are covered in fixing "Error establishing a database connection".
MySQL is a trademark of Oracle Corporation. MariaDB is a trademark of MariaDB Foundation. ESAGAMES is an independent hosting provider, not affiliated with or endorsed by Oracle.