I'm getting "ERR max number of clients reached" for my Redis, how can I avoid this?


You're seeing the error ERR max number of clients reached and running out of connections in your Heroku Redis instance.


Each of the Heroku Redis plans has a limit on the number of clients that can be connected to the Redis service.

For the smallest plans, such as the mini plan (20 clients max.) or the premium-0 plan (40 clients max.), an application can quickly reach the connection limit if it's not properly configured and it tries to open more connections than allowed.

The Heroku Redis metrics logs can help monitor the number of active connections for your instance. However, if your application is suddenly opening a high number of connections and hitting the limit, this behavior might not be reflected in the metrics if the connection spike is short enough that it isn't caught by the metric samples.

There are several things you can do to avoid hitting the limit of concurrent connected clients, such as using a connection pooler to reduce the number of connections or setting an appropriate connection timeout to close inappropriate idle connections.

You can also configure your Heroku Redis instance to automatically close idle connections after a specific timeout with the heroku redis:timeout command.

The following blog post goes through the above recommendations on connection timeouts and connection pooling, and includes other useful tips: https://blog.heroku.com/real-world-redis-tips

With Redis 6, the max. number of clients reached errors can also present as SSL_connect SYSCALL returned=5 errno=0 state=SSLv3/TLS write client hello, given that Redis is rejecting the connection before the SSL handshake can succeed.

WARNING: Starting November 28, 2022, free Heroku Dynos, free Heroku Postgres, and free Heroku Data for Redis plans will no longer be available. If you have apps using any of these resources, you must upgrade to paid plans by this date to ensure your apps continue to run and retain your data. Heroku Connect and Heroku Scheduler free plans and other third-party add-ons are not affected. Eligible students can apply for platform credits through our new Heroku for GitHub Students program. See our blog and FAQ for more info.

Ask on Stack Overflow

Engage with a community of passionate experts to get the answers you need

Ask on Stack Overflow

Heroku Support

Create a support ticket and our support experts will get back to you

Contact Heroku Support