1

I'm trying deploying my application wherein im using workers and ques for jobs, trying to connect the redis instance to my application , connection is getting refused. I thik app still trying to hit a local connection. Here is my redis.js in config

const redis = require('redis');

// Redis configuration options
const redisConfig = {
  url: 'redis://red-cjds7cavvtos73bpvvn0:6379',
  host: 'red-cjds7cavvtos73bpvvn0'
};
console.log('redis config started with redis url: ',redisConfig.url)
// Create a Redis client
const client = redis.createClient(redisConfig);
console.log("client added: ",client)
// Event listeners for Redis client
client.on('connect', () => {
  console.log('Connected to Redis');
});

client.on('error', (error) => {
  console.error('Error connecting to Redis:', error);
});
console.log('exporting the connection')

// Export the Redis client
module.exports = client;

following is my import of the config file in server's root index

const express = require('express')
const app = express();
const redisConnection=require('./config/redis')
const path = require('path')
const port = 7000
const db = require('./config/mongoose')

following is the error in the deployement logs on render:

==> Using Node version 14.17.0 (default)
Aug 19 04:40:37 AM  ==> Docs on specifying a Node version: https://render.com/docs/node-version
Aug 19 04:40:37 AM  ==> Starting service with 'node index.js'
Aug 19 04:40:43 AM  redis config started with redis url:  redis://red-cjds7cavvtos73bpvvn0:6379
Aug 19 04:40:43 AM  client added:  Commander {
Aug 19 04:40:43 AM    _events: [Object: null prototype] {},
Aug 19 04:40:43 AM    _eventsCount: 0,
Aug 19 04:40:43 AM    _maxListeners: undefined,
Aug 19 04:40:43 AM    commandOptions: [Function: commandOptions],
Aug 19 04:40:43 AM    select: [AsyncFunction: SELECT],
Aug 19 04:40:43 AM    subscribe: [Function: SUBSCRIBE],
Aug 19 04:40:43 AM    unsubscribe: [Function: UNSUBSCRIBE],
Aug 19 04:40:43 AM    pSubscribe: [Function: PSUBSCRIBE],
Aug 19 04:40:43 AM    pUnsubscribe: [Function: PUNSUBSCRIBE],
Aug 19 04:40:43 AM    sSubscribe: [Function: SSUBSCRIBE],
Aug 19 04:40:43 AM    sUnsubscribe: [Function: SUNSUBSCRIBE],
Aug 19 04:40:43 AM    quit: [Function: QUIT],
Aug 19 04:40:43 AM    multi: [Function: MULTI],
Aug 19 04:40:43 AM    bf: {},
Aug 19 04:40:43 AM    cms: {},
Aug 19 04:40:43 AM    cf: {},
Aug 19 04:40:43 AM    tDigest: {},
Aug 19 04:40:43 AM    topK: {},
Aug 19 04:40:43 AM    graph: {},
Aug 19 04:40:43 AM    json: {},
Aug 19 04:40:43 AM    ft: {},
Aug 19 04:40:43 AM    ts: {},
Aug 19 04:40:43 AM    [Symbol(kCapture)]: false
Aug 19 04:40:43 AM  }
Aug 19 04:40:43 AM  exporting the connection
Aug 19 04:40:48 AM  server is ua and running on port: 7000
Aug 19 04:40:48 AM  events.js:353
Aug 19 04:40:48 AM        throw er; // Unhandled 'error' event
Aug 19 04:40:48 AM        ^
Aug 19 04:40:48 AM  
Aug 19 04:40:48 AM  Error: connect ECONNREFUSED 127.0.0.1:6379
Aug 19 04:40:48 AM      at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16)
Aug 19 04:40:48 AM  Emitted 'error' event on Queue instance at:
Aug 19 04:40:48 AM      at RedisClient.<anonymous> (/opt/render/project/src/node_modules/kue/lib/redis.js:65:13)
Aug 19 04:40:48 AM      at RedisClient.emit (events.js:376:20)
Aug 19 04:40:48 AM      at RedisClient.on_error (/opt/render/project/src/node_modules/kue/node_modules/redis/index.js:401:14)
Aug 19 04:40:48 AM      at Socket.<anonymous> (/opt/render/project/src/node_modules/kue/node_modules/redis/index.js:279:14)
Aug 19 04:40:48 AM      at Socket.emit (events.js:376:20)
Aug 19 04:40:48 AM      at emitErrorNT (internal/streams/destroy.js:106:8)
Aug 19 04:40:48 AM      at emitErrorCloseNT (internal/streams/destroy.js:74:3)
Aug 19 04:40:48 AM      at processTicksAndRejections (internal/process/task_queues.js:82:21) {
Aug 19 04:40:48 AM    errno: -111,
Aug 19 04:40:48 AM    code: 'ECONNREFUSED',
Aug 19 04:40:48 AM    syscall: 'connect',
Aug 19 04:40:48 AM    address: '127.0.0.1',
Aug 19 04:40:48 AM    port: 6379
Aug 19 04:40:48 AM  }

please help!

I tried adding host to the connection configurations but still it's not connecting correcly please help me establish the redis connection

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.