Skip to content
Linux & VPS

Fix MySQL "Too Many Connections" Error

Too many connectionsERROR 1040can't connect to database
7 min read Updated 12 June 2026 ESAGAMES Team

"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.

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 connected

Quick 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 = 300
Raising it isn't always the answer

If 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".

Databases that stay up

Our managed hosting tunes MySQL/MariaDB for your workload, so game panels and sites stay connected.

See hosting
FAQ

Frequently asked questions

What causes MySQL "Too many connections"?

More simultaneous connections than max_connections allows. Either real load outgrew the limit, or an app is opening connections without closing them (a leak). SHOW PROCESSLIST shows what's connected.

How do I fix it quickly?

Raise the limit live with SET GLOBAL max_connections = 300; to get back online, and set it in my.cnf to persist. Then investigate why so many connections are open.

Should I just keep raising max_connections?

No. Each connection uses memory, so raising it too high can crash the server. If connections keep filling up, fix the app that's leaking them or the slow queries holding connections open.

How do I find which app or script is causing "too many connections"?

Run SHOW PROCESSLIST (or query information_schema.processlist) and group by user/host — a single source opening far more connections than the others is usually the leak.

What is a safe max_connections value for a small VPS?

It depends on available RAM, since each connection reserves memory. As a rough guide, keep max_connections low enough that connections × per-connection memory stays well under total RAM — a few hundred is often the practical ceiling on a small VPS, not thousands.

Can a WordPress plugin cause "too many connections"?

Yes — a plugin that opens a new database connection per request without closing it (or a broken caching layer) is a common cause on WordPress sites, especially under bot or crawler traffic.

Further reading

Go deeper on this

Guides and explainers that pair with this fix — from our guides and blog.

Knowledge base

Related articles

Skip the troubleshooting

Managed, protected hosting in Frankfurt — we handle the Linux, the network and the DDoS so you don't have to.

Payments Secure checkout with cards, banking apps and digital wallets.

Choose the payment flow that fits your stack and region without leaving the platform.

Pay by Zen Visa Mastercard Paysafecard PaysafeCash Skrill Trustly Bancontact UnionPay iDeal WebMoney