MySQL ERROR 1040: Too many connections - Rocketeers 8" x-data="{ menu: false, scrolled: false }" x-effect="document.body.style.overflow = menu ? 'hidden' : ''"&gt;

 On this page

 Knowledge
---------

MySQL ERROR 1040: Too many connections
======================================

### [\#Databases](https://rocketee.rs/index.php/databases)

This error means MySQL hit its max\_connections limit and is refusing new clients. Raise the limit if it is genuinely too low, but first rule out leaked connections.

 Published by Mark van Eijk on June 23, 2026 · 1 minute read

1. [About the error](#content-about-the-error)
2. [Why do I see this error](#content-why-do-i-see-this-error)
3. [Solution](#content-solution)
4. [See what's using the connections](#content-see-whats-using-the-connections)
5. [Raise the limit](#content-raise-the-limit)
6. [Reclaim idle connections faster](#content-reclaim-idle-connections-faster)
7. [Fix the real cause in the app](#content-fix-the-real-cause-in-the-app)

[\#](#content-about-the-error "Permalink")About the error
---------------------------------------------------------

 ```
ERROR 1040 (HY000): Too many connections

```

MySQL allows a fixed number of simultaneous client connections (`max_connections`, default 151). Once that ceiling is reached, every new connection is rejected until an existing one closes. For a web app this surfaces as failed requests across the whole site.

[\#](#content-why-do-i-see-this-error "Permalink")Why do I see this error
-------------------------------------------------------------------------

- `max_connections` is genuinely too low for your traffic.
- A **connection leak**: the application opens connections but never closes them.
- Long-running queries holding slots open, see `SHOW PROCESSLIST`.
- A connection pool misconfigured to exceed the server's limit.
- A real traffic spike.

[\#](#content-solution "Permalink")Solution
-------------------------------------------

### [\#](#content-see-whats-using-the-connections "Permalink")See what's using the connections

You'll usually need an account with the `SUPER` privilege (MySQL reserves one extra slot for it) to get in when full:

 ```
SHOW PROCESSLIST;
SHOW STATUS WHERE Variable_name = 'Threads_connected';

```

If you see dozens of idle `Sleep` connections, that's a leak or idle sessions not being reaped, not a reason to keep raising the limit.

### [\#](#content-raise-the-limit "Permalink")Raise the limit

Temporarily, without a restart:

 ```
SET GLOBAL max_connections = 300;

```

Permanently, in `my.cnf` under `[mysqld]`:

 ```
[mysqld]
max_connections = 300

```

Then restart MySQL. Don't set this arbitrarily high, each connection consumes memory, and a too-high value can exhaust RAM and take the server down harder than the original error.

### [\#](#content-reclaim-idle-connections-faster "Permalink")Reclaim idle connections faster

Lower the idle timeouts so abandoned connections free their slots sooner:

 ```
wait_timeout = 120
interactive_timeout = 120

```

### [\#](#content-fix-the-real-cause-in-the-app "Permalink")Fix the real cause in the app

For a Laravel app, make sure you're not opening connections in a loop and that long jobs run on a queue rather than holding a web request open. A leak will exhaust any limit you set. Related: [SQLSTATE\[HY000\] \[2002\] Connection refused](/sqlstate-hy000-2002-connection-refused) when MySQL can't be reached at all.

### Subscribe to our newsletter

Do you want to receive regular updates with fresh and exclusive content to learn more about web development, hosting, security and performance? Subscribe now!

  Fill in your email address to receive updates  Subscribe 

#### Related articles

[Stream MySQL backup directly to S3 bucket](https://rocketee.rs/index.php/stream-mysql-backup-s3-bucket)
--------------------------------------------------------------------------------------------------------

This error means MySQL hit its max\_connections limit and is refusing new clients. Raise the limit if it is genuinely too low, but first rule out leaked connections.

[Read more →](https://rocketee.rs/index.php/stream-mysql-backup-s3-bucket)

[Export MySQL database using command line](https://rocketee.rs/index.php/export-database-mysql-command-line)
------------------------------------------------------------------------------------------------------------

This error means MySQL hit its max\_connections limit and is refusing new clients. Raise the limit if it is genuinely too low, but first rule out leaked connections.

[Read more →](https://rocketee.rs/index.php/export-database-mysql-command-line)
