DBAtlas · Database operations atlas

1040: Too many connections

MySQL

What does it mean?

The server reached the maximum number of concurrent connections allowed by max_connections; new connections are being rejected.

Why does it happen?

A wrongly sized connection pool, connection leaks, many short-lived connections, connections sleeping for a long time (Sleep) or a max_connections value too low for the workload.

How to fix it

Inspect connections: SHOW PROCESSLIST or SELECT * FROM performance_schema.processlist. Close unnecessary sleeping connections with KILL. Increase max_connections: SET GLOBAL max_connections = 500 (my.cnf to persist). The root fix is using a connection pool and closing idle connections with wait_timeout. One extra emergency admin connection is reserved for SUPER/CONNECTION_ADMIN.

Open in DBAtlas →

More from this engine