Skip to content

Troubleshooting guide

Redis "max number of clients reached": how to fix it

Redis has reached its connection limit and is refusing new clients. Leaks and missing pooling are far more common than a limit that is genuinely too low.

3 min read10 sectionsUpdated

On this page

Key points

  • CLIENT LIST shows who is connected and for how long idle.
  • The default is 10,000, reduced if file limits are low.
  • Connecting per request is a typical leak.
  • Slow commands make clients queue and pile up.

What it means

Each client uses a file descriptor and memory on the server. When maxclients is reached, a new connection receives this error and gets dropped. Because a cache is commonly in the path of every request, the application can go down all at once.

Common causes

  • A new connection on every request that is not closed.
  • A connection per pod multiplied by autoscaling.
  • Blocked or very slow commands causing clients to stack up.
  • Low ulimit silently reducing maxclients at startup.

Diagnose it

Group connected clients by origin and idle time.

bash
# Current and maximum
redis-cli INFO clients | grep connected_clients
redis-cli CONFIG GET maxclients

# Clients per source address
redis-cli CLIENT LIST | awk '{print $2}' | cut -d= -f2 | cut -d: -f1 | sort | uniq -c | sort -rn | head

# Long-idle connections
redis-cli CLIENT LIST | tr ' ' '\n' | grep '^idle=' | cut -d= -f2 | sort -n | tail -5

# Did Redis lower the limit at startup?
grep -i 'maxclients\|open files' /var/log/redis/redis-server.log | tail

Fixes

Reuse a single multiplexed client (Node ioredis, StackExchange.Redis) or a bounded pool. Create the client once at startup, never within a handler. Set timeout 300 in Redis so abandoned idle connections close. Raise maxclients with a matching file limit, using LimitNOFILE in systemd, if the count is legitimate. Consider a proxy such as Twemproxy for very large fleets.

Find the leak by shape

A leak has a recognisable pattern. Connections from one application rise steadily and only fall when that application restarts. On a chart this is a sawtooth aligned with deployments. Many connections from one address with high idle times indicate an unreturned pool or a client created per job. Set a client name with CLIENT SETNAME at connection time, so CLIENT LIST shows which service owns each connection, a small change that pays off the first time this happens.

Catch it automatically

Alert at 80 percent of maxclients in Redis monitoring, and treat a rising connection count without rising traffic as a leak. Log management can alert on the exact error message.

Frequently asked questions

What is the default maxclients?

It is 10,000, unless the process file limit forces a lower value.

Do I need a connection pool for Redis?

Multiplexed clients work with a single connection. Use a pool for blocking commands or clients without multiplexing.

What does timeout do?

It closes client connections that have been idle longer than the given number of seconds.

Watch your own site and services with VitalRix

Uptime checks, APM, logs, real-user monitoring, alerts and status pages in one place. Every product has a free tier and no credit card is needed.