MySQL ERROR 1040 (08004): Too many connections
MySQL reached max_connections and refuses new clients.
Too many connectionsremaining connection slots are reserved Meaning
Each client connection uses memory, so MySQL caps them (default 151). Leaking connections, unbounded worker counts, persistent connections from many PHP-FPM children, or slow queries piling up exhaust the limit. Shared hosting often has a per-user cap (max_user_connections, error 1203).
Common causes
- Connections not closed / connection leaks
- Too many app workers each holding a pool
- Slow queries keeping connections busy so new ones pile up
- Persistent connections × many PHP-FPM processes
- Per-user limit on shared hosting
⚡ Quick fix
- See who is connected:
SHOW PROCESSLIST; - Fix slow queries causing pile-ups
- Right-size pools: workers × pool size < max_connections
- Raise max_connections only if RAM allows
Detailed fix by platform
MySQL
- Inspect and adjust:sql
SHOW VARIABLES LIKE 'max_connections'; SHOW STATUS LIKE 'Max_used_connections'; SELECT user, host, COUNT(*) FROM information_schema.processlist GROUP BY user, host ORDER BY 3 DESC; SET GLOBAL max_connections = 300; -- also persist in my.cnf
Node.js
- Create ONE pool per process (e.g.
mysql2.createPool({ connectionLimit: 10 })), not a connection per request.
How to diagnose
- Usage — Max_used_connections vs max_connections
- Who — Which user/host holds most connections?
- State — Many in Sleep (leak) or Query (slow)?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
Most viewed in MySQL
Other ways to find it
Where this error sits
Origin: Data. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 13 Oct 2026