How do I connect my app to Redis Labs server?

Viewed 2436

I've been trying to connect my node app to my remote Redis Labs server. I have the endpoint which from what I can discover, is my host and port (host.com:port). I've been trying to connect to the cloud server by using

const redis = require('redis');
const client = redis
  .createClient(process.env.REDIS_PORT, process.env.REDIS_HOST)
  .on('error', err => console.error('FUCK', err));

client.on('connect', function(err, res) {
  console.log('redis is connected!');
});

but I continue to get an error. "Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED 127.0.0.1:6379"

I'm sure this is a simple fix, but I just don't understand how to get it to work. Any help would be much appreciated!

1 Answers

Figured it out. I knew it was a simple fix. Just had to call client.auth(process.env.REDIS_PASSWORD)

const client = redis.createClient(
  process.env.REDIS_PORT,
  process.env.REDIS_HOST
);
client.auth(process.env.REDIS_PASSWORD);
Related