# ERR max number of clients reached

```json metadata
{
  "schema_version": 2,
  "title": "ERR max number of clients reached",
  "description": "The server already has as many connections as its limit allows.",
  "categories": ["docs","develop","stack","oss","rs","rc","oss","kubernetes","clients"],
  "tableOfContents": {"sections":[{"id":"how-to-fix-it","title":"How to fix it"}]}

,
  "codeExamples": []
}
```


Redis returns this error when a new client connects, but the server already has as many connections as its limit allows. The limit is the `maxclients` setting, which is 10,000 by default. Redis sends the error and then closes the new connection.

```
ERR max number of clients reached
```

In a cluster, the connections from other cluster nodes count toward the limit too, and the message is `ERR max number of clients + cluster connections reached`.

In redis-py, this error is `ConnectionError: max number of clients reached`.

## How to fix it

1. Check how many clients are connected with [`INFO clients`](https://redis.io/docs/latest/commands/info). `connected_clients` shows the number of connections, and `maxclients` shows the limit.
1. Find out where the connections come from with [`CLIENT LIST`](https://redis.io/docs/latest/commands/client-list). Each line shows a connection's address in `addr`, its name in `name`, and how many seconds it has been idle in `idle`. Many connections from the same app that stay idle for a long time usually mean that the app doesn't close them.
1. Fix the cause:
    - **Your app opens a new connection for each request.** Create one client, or one connection pool, when your app starts, and reuse it. For example, see [Connect with a connection pool](https://redis.io/docs/latest/develop/clients/redis-py/connect#connect-with-a-connection-pool) for redis-py.
    - **Many copies of your app each keep a large pool.** The total number of connections is the pool size multiplied by the number of copies. Make the pools smaller.
    - **Idle connections never close.** By default, Redis never closes idle connections. Set `timeout` to the number of seconds after which Redis closes an idle connection. See [Client timeouts](https://redis.io/docs/latest/develop/reference/clients#client-timeouts).
    - **You need more connections.** Raise `maxclients`. Each connection also uses a file descriptor, so check the operating system's limit too. See [Maximum concurrent connected clients](https://redis.io/docs/latest/develop/reference/clients#maximum-concurrent-connected-clients).

