1040: Too many connections
MySQLWhat 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.
More from this engine
- 1062Duplicate entry for key
- 1213Deadlock found when trying to get lock; try restarting transaction
- 1205Lock wait timeout exceeded; try restarting transaction
- 1064You have an error in your SQL syntax
- 1146Table doesn't exist
- 1054Unknown column in field list
- 2002Can't connect to local MySQL server through socket