ERR max number of clients reached
The server already has as many connections as its limit allows.
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 client libraries
| Client library | Exception or error type | Message |
|---|---|---|
| redis-py | ConnectionError |
max number of clients reached |
| Jedis | JedisConnectionException |
Unexpected end of stream. |
| node-redis | SimpleError |
ERR max number of clients reached |
| Lettuce The async API wraps the exception in an ExecutionException (get()) or a CompletionException (join()). |
RedisConnectionException |
Unable to connect to <host>/<unresolved>:<port>The cause is a RedisCommandExecutionException with the message ERR max number of clients reached. |
| go-redis | io.EOF |
EOFThe server closes the connection after it sends the error, and go-redis reported EOF in our run, not the error text. |
| ioredis | Error |
Connection is closed.The server closes the connection after it sends the error. |
| StackExchange.Redis NRedisStack uses StackExchange.Redis, so it raises the same exceptions. The sync and async APIs raise the same exceptions. |
RedisConnectionException |
It was not possible to connect to the redis server(s). Error connecting right now. To allow this multiplexer to continue retrying until it's able to connect, use abortConnect=false in your connection string or AbortOnConnectFail=false; in your code.Connect raises this error when the server refuses the connection. |
| Predis | Predis\Connection\ConnectionException |
Stream is already at the end [tcp://<host>:<port>] |
| redis-rb | Redis::CannotConnectError |
EOFError (redis://<host>:<port>) (redis://<host>:<port>) |
| redis-rs The sync and async APIs raise the same errors. |
ErrorKind::Io |
unexpected end of fileThe server closes the connection after it sends the error. The async API reports broken pipe. |
How to fix it
- Check how many clients are connected with
INFO clients.connected_clientsshows the number of connections, andmaxclientsshows the limit. - Find out where the connections come from with
CLIENT LIST. Each line shows a connection's address inaddr, its name inname, and how many seconds it has been idle inidle. Many connections from the same app that stay idle for a long time usually mean that the app doesn't close them. - 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 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
timeoutto the number of seconds after which Redis closes an idle connection. See 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.