ERROR 1040 (HY000): Too many connections means new sessions are being refused because the count of open connections reached max_connections. The instinct to raise the limit is understandable and sometimes right, but the common cause is connections accumulating faster than they close: an application that opens without closing, a pool configured larger than the server allows across all its instances, or long-lived idle sessions nobody reaps. MySQL reserves one extra connection above the limit for a privileged account, which is the administrator's way in to fix it.
SHOW PROCESSLIST; or query information_schema.processlist, grouped by user, host, and state. The picture is usually unmistakable: hundreds of connections from one application host in Sleep state, or a flood from a single misbehaving client.SHOW STATUS LIKE 'Threads_connected'; and Max_used_connections show the current load and the historical peak, and SHOW VARIABLES LIKE 'max_connections'; the configured ceiling.wait_timeout so abandoned sessions are reaped sooner, and let pools validate and retire idle connections on their side too.max_connections is legitimate when the load is real, sized with memory in mind: each connection carries per-session buffers, so thousands of connections can consume gigabytes; on systemd-managed installs the setting also depends on the service's open-files limit, which the error log warns about when it becomes the binding constraint.Why does restarting MySQL “fix” it temporarily? Restarting drops every connection, so the count resets. If the cause is a leak or pool arithmetic, the count climbs back on the same schedule as before, which is itself the confirmation of the cause.
Can one bad client lock out everyone? Yes. Connections are a shared pool; a single client leaking or storming connections can consume them all. The processlist grouped by host identifies it, and killing its sessions (KILL <id>) is a valid immediate relief while the client is fixed.
What is a sensible max_connections? There is no universal number; it should exceed the summed pool maxima of all clients with headroom, and stay within what the host's memory supports. Hundreds is typical for application servers; tens of thousands is a design problem, not a setting.