Redis Connection Error with Heroku Redis Instance: Redis connection to failed - read ECONNRESET heroku instance

3.3k Views Asked by At

I have a node js app. And I use Redis from Heroku Redis(with async-redis library). Actually, I have two different Heroku accounts and two different Node.js apps hosted by Heroku. But except Redis credentials, both apps are the same code.

The interesting thing on my app I can connect to first Heroku Redis instance. But I can't connect to new Heroku Redis instance. Besides I deleted and created new instances, bu they don't work.

The error is:

    Error: Redis connection to redis-123.compute.amazonaws.com:28680 failed - read ECONNRESET\n    
at TCP.onStreamRead (internal/stream_base_commons.js:162:27)

My connection statement like this:

var redisPassword = 'password123';
var redisOptions = { host: 'redis-123.cloud.redislabs.com', port: '17371', auth_pass: redisPassword }
//var redisPassword = 'password123';
//var redisOptions = { host: 'redis-123.compute.amazonaws.com', port: '28680', auth_pass: redisPassword }

const client = redis.createClient(redisOptions);

client.on('connect', function () {
  console.log('Redis client connected');
});

client.on('error', function (err) {
  console.log('An error on Redis connection: ' + err);
});

As I can see there is the only thing that different on Heroku Redis instances. My first Redis instance hosts at cloud.redislabs.com but the second instance(that i can't connect) hosts at compute.amazonaws.com.

Any help will be much appreciated.

3

There are 3 best solutions below

0
On BEST ANSWER

I couldn't find the root problem. But after comment of Chris, I checked again Heroku Redis addons I used. enter image description here

Heroku Redis gives me an instance from amazonaws.com, and Redis Enterprise Cloud gives me an instance from redislabs.com. When I added and used Redis Enterprise Cloud, I could connect to it.

But Heroku Redis's connection problem still is a secret for me.

0
On

I encountered this situation and it turned out the with "Heroku Redis" connecting via TLS worked (the url that starts with rediss) once I adjusted my client code to connect following the example provided in the Heroku redis docs:

https://devcenter.heroku.com/articles/connecting-heroku-redis#ioredis-module

const Redis = require("ioredis");

const client = new Redis(process.env.REDIS_URL, {
    tls: {
        rejectUnauthorized: false
    }
});

Where process.env.REDIS_URL is rediss://<details>

0
On

It looks like Redis on Heroku will have a ECONNRESET if you try to connect to the TLS endpoint, but you have exceeded the max number of connections. The non TLS-endpoint (if it is available) will return a more helpful error message.

More info here from Heroku.