The Too many connections error (1040) means MySQL or MariaDB has reached the number of connections it will accept. Raising max_connections may create headroom during an incident, but it does not fix a leak, an oversized pool, queries holding connections, or a memory-constrained VPS. Preserve an administrative session, capture evidence, and reduce pressure before changing the limit.
This guide covers MySQL 8.x and current MariaDB releases on systemd-based Linux systems. Unit names, paths, privileges, and variables can differ by package, container, or provider. The commands are documented examples checked statically; they were not run against a real server. MariaDB’s official guide to handling too many connections likewise starts from observing the limit and workload before sizing.
What each symptom suggests
| Symptom | Reading | Next check |
|---|---|---|
Threads_connected approaches max_connections while Threads_running stays low. | Many sessions are connected, but few are doing work. | Group by user, host, and COMMAND; calculate total pool capacity. |
| Both counters are high. | There is real concurrency, waiting, or slow work. | Inspect states, elapsed time, slow queries, and CPU/I/O load. |
Max_used_connections reached the limit during one spike. | It may be legitimate demand or a retry burst. | Correlate timestamps with traffic, deploys, and application errors. |
Many connections show Sleep. | This may be normal reuse or excessive retention; it does not prove a leak. | Compare age, creation rate, and pool settings. |
| The setting disappears after restart. | Only the in-memory global changed, or an ineffective file was edited. | Identify the product and effective configuration source. |
Before you intervene
You need provider console or local access, an already-open administrative session if one exists, a change window, and a recoverable backup. Keep a second system session open; do not close the only useful SQL connection. If this is your first incident, review what you control on a VPS.
Never pass a password as -pPASSWORD or paste one into history. Use socket authentication, an existing login path, or a protected option file. Do not publish SHOW FULL PROCESSLIST: hosts, databases, and SQL may be sensitive.
Prepare and test SQL administration before an incident. MariaDB reserves one connection above max_connections for an account with SUPER or CONNECTION ADMIN; some installations also support a preconfigured extra port. MySQL reserves one connection on the ordinary interface for CONNECTION_ADMIN or the deprecated SUPER. Its separate administrative interface exists only when admin_address was configured at startup and requires SERVICE_CONNECTION_ADMIN. Verify release, privileges, TLS/networking, and protected credentials; managed services may restrict these features. The MariaDB system variable reference documents its mechanisms.
A system console does not create a SQL slot. If you preserved no session and never tested reserved access, use the console to reduce or stop application traffic first and release a connection; do not restart the database blindly.
1. Confirm the product, limit, and current pressure
Run read-only queries first from the secured session. The version and version_comment prevent you from applying MySQL syntax to MariaDB. Max_used_connections is a high-water mark since startup or a status reset, not current concurrency. Connection_errors_max_connections records limit rejections where the release exposes it; if no row returns, check the available equivalent and server logs instead of treating it as zero.











