Unable to connect to Redis instance from Nestjs app

Using Nestjs

ClientsModule.register([
      {
        name: 'redis',
        transport: Transport.REDIS,
        options: {
          host: 'red-cobslh....',
          port: 6379,
        },
      },
    ]),
    BullModule.forRoot({
      redis: {
        host: 'red-cobslh6n7....',
        port: 6379,
      },
    }),

using Nestjs bull, bull package
connect via the Internal url of redis render
Both web service and redis also in Render

But when deployed the webservice, it keep give me this error

[Nest] 68 - 04/12/2024, 10:14:48 AM ERROR [Server] Error: connect ECONNREFUSED 127.0.0.1:6379

Apr 12 06:14:48 PM[Nest] 68 - 04/12/2024, 10:14:48 AM ERROR [Server] Error: connect ECONNREFUSED 127.0.0.1:6379

Apr 12 06:14:48 PM[Nest] 68 - 04/12/2024, 10:14:48 AM ERROR [Server] Retry time exhausted

Apr 12 06:14:48 PM/opt/render/project/src/node_modules/ioredis/built/Redis.js:207

Apr 12 06:14:48 PM reject(new Error(utils_1.CONNECTION_CLOSED_ERROR_MSG));

Apr 12 06:14:48 PM ^

Apr 12 06:14:48 PM

Apr 12 06:14:48 PMError: Connection is closed.

Apr 12 06:14:48 PM at EventEmitter.connectionCloseHandler (/opt/render/project/src/node_modules/ioredis/built/Redis.js:207:28)

Apr 12 06:14:48 PM at Object.onceWrapper (node:events:629:26)

Apr 12 06:14:48 PM at EventEmitter.emit (node:events:514:28)

Apr 12 06:14:48 PM at process.processTicksAndRejections (node:internal/process/task_queues:77:11)

Apr 12 06:14:48 PM

Apr 12 06:14:48 PM

tripled check in local, the code is able to start, able to connect to redis, all the queue microservices is able to connect and send to queue etc

tried using Environment variable
tried using url: redis://... blah blah for BullModule

all didnt work, all getting the same error

It keep giving me connect to LOCALHOST, i dont know why, I already specify it as pure string inside the app also unable to work

All webservice and Redis also in the same region.

Please give me a solution on this.
What else I need to do to make this work?

Hi,

I’ve replied to the ticket you also opened. Let’s keep the conversation in one place (on the ticket).

However, I’ll repeat the response here:

The logs show you’re trying to connect to Redis on 127.0.0.1

ERROR [Server] Error: connect ECONNREFUSED 127.0.0.1:6379

Redis instances are not on localhost / 127.0.0.1. You’ll need to update your code/config to connect using the “Internal Redis URL” details on the Redis service page.

Alan

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.