## TL;DR
The server hit `max_connections`: find the leak (sleeping connections piling up) with `SHOW PROCESSLIST`, fix the app to close or pool connections, and only then raise `max_connections` (each connection costs RAM). The error stops once usage fits the limit.

## Error
```text
mysql: Too many connections
```

## Steps
1. Inspect the connection list: run `SHOW FULL PROCESSLIST` and count by state and user. Expected: you see whether connections are sleeping (leak) or actively working (genuine load).
2. Find the leak: sleeping connections from one app host point at missing close calls or no pooling. Expected: the offending client identified.
3. Fix the client: add connection pooling (or fix the close logic) so connections are reused. Expected: the sleeping pileup stops growing.
4. Tune the server: raise `max_connections` modestly, accounting for per-connection memory, and consider lowering `wait_timeout` to reap idle ones faster. Expected: headroom for legitimate peaks.
5. Add a proxy (like ProxySQL) if connection counts keep growing with traffic. Expected: the database sees a bounded pool regardless of app instances.

## When to use
- MySQL refuses connections with "Too many connections"
- After adding app instances or workers
- Auditing connection hygiene

## When not to use
- Access denied for user (authentication)
- The server is up but slow (performance tuning)

## Tool compatibility
- MySQL `max_connections`, `wait_timeout`, `SHOW PROCESSLIST`; connection poolers

## Variant phrasings
### mysql sleeping connections pile up
The app is not closing them; add pooling or fix the close path.

### raise max_connections safely
Budget RAM per connection and lower `wait_timeout`; the limit is not free.

## Why it happens
Each MySQL connection consumes server memory and a thread, so the server caps them. Applications that open a connection per request without pooling exhaust the cap under load, and the fix is architectural (pooling) more than numerical (a bigger cap).

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_GVOWZISLxc6E41-8ej9LOQ
