#Ioredis Node connection issue.

41 messages · Page 1 of 1 (latest)

cloud bone
#
    const redisConnection: RedisOptions = {
      host: `http://${process.env.REDIS_HOST}`,
      port: Number(process.env.REDIS_PORT),
      password: process.env.REDIS_PASS,
      username: process.env.REDIS_USER,
      family: 0,
      retryStrategy: (times) => {
        // reconnect after
        return Math.min(times * 50, 2000);
      },
    };

My connection object above

[ioredis] Unhandled error event: Error: getaddrinfo ENOTFOUND http://redis-cache-staging.railway.internal

rain kettleBOT
#

Project ID: 13314144-b328-475d-867f-a0337164519f

cloud bone
#

13314144-b328-475d-867f-a0337164519f

#

I have set the family as you can see

#

i also have sleep 3 in my start command

stable matrix
#

nixpacks or dockerfile?

cloud bone
#

nixpacks with the sleep command in the package.json start command

stable matrix
#

according to the redis service settings, is that host correct?

cloud bone
#

redis-cache-staging.railway.internal

Should i have the http infront ?

stable matrix
#

redis does not use http

cloud bone
#

kkk let me check. should i justhave

redis-cache-staging.railway.internal

stable matrix
#

is the redis database in the same environment as the service thats trying to connect to it

cloud bone
#

yes

stable matrix
#

are you sure the sleep 3 is being ran?

cloud bone
#

yes

stable matrix
#

how so?

cloud bone
#

i have removed http:// and redeploying now to check

#

[ioredis] Unhandled error event: Error: connect ECONNREFUSED 127.0.0.1:6379
at __node_internal_captureLargerStackTrace (node:internal/errors:496:5)
at __node_internal_exceptionWithHostPort (node:internal/errors:671:12)
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16)

#
    const redisConnection: RedisOptions = {
      host: process.env.REDIS_HOST,
      port: Number(process.env.REDIS_PORT),
      password: process.env.REDIS_PASS,
      username: process.env.REDIS_USER,
      family: 0,
      retryStrategy: (times) => {
        // reconnect after
        return Math.min(times * 50, 2000);
      },
    };
#

Host is set correctly in the variables

stable matrix
#

you are still using shared variables

cloud bone
#

i have applied everything from the railway docs

stable matrix
#

please stop using shared variables for this

#

use reference variables

cloud bone
#

ok changed from shared variables, using reference vars from redis service

#

Redis port has gone blank on the redis service

stable matrix
#

use the private url variable please

#

just like the example in the docs shows

cloud bone
#

Ok using the private url string only works. But i wonder why you cannot construct using the options with all the same details

stable matrix
#

probably just configured it wrong

void reefBOT
cloud bone
#

@stable matrix thanks for all the help man. appreciate it

stable matrix
#

no problem

dreamy knotBOT
#

New reply sent from Help Station thread:

Hi sorry to bring this back up, but I'm not able to see the messages on discord, and I think many links are missing here.What is the right solution to get a redis instance running within the same project? I'm having issues with the host being undefined.

You're seeing this because this thread has been automatically linked to the Help Station thread.

#

New reply sent from Help Station thread:

No worries, the links are indeed missing.Getting ioredis setup correctly with private networking checklist -Make sure you have the V2 runtime enabled in your service settings.Use the URL syntax for the ioredis client as shown here - https://github.com/redis/ioredis/blob/main/README.md#connect-to-redisUse environment variables.Append ?family=0 to the end of the URL.Example -const redis = new Redis(process.env.REDIS_URL + "?family=0");

You're seeing this because this thread has been automatically linked to the Help Station thread.

GitHub

🚀 A robust, performance-focused, and full-featured Redis client for Node.js. - redis/ioredis

dreamy knotBOT
#

New reply sent from Help Station thread:

Hi, I'm still having this exact issue.
I'm running:
ioredis 5.5.0
node 22.8.0
I'm configuring the redis instance like this:

const redisClient = new Redis(`${process.env.REDIS_URL}?family=0`, {
    tls: { rejectUnauthorized: false },
    lazyConnect: true,
    connectTimeout: 15000,
    retryStrategy: (times) => Math.min(times * 30, 1000),
  });

My redis url looks like this when I print it out: redis://default:[email protected]:6379
I'm using setting the REDIS_URL variable like this on railway:
${{Redis.REDIS_URL}}
Also regarding @brody's checklist, "ensure V2 runtime enabled" - I cannot see such on option on either my redis-service or my backend-service config. Is there another way to configure this?
Thanks in advance!

You're seeing this because this thread has been automatically linked to the Help Station thread.

dreamy knotBOT
#

New reply sent from Help Station thread:

Can you please open your own help thread, a new thread would be preferable over an 8 month old thread.

You're seeing this because this thread has been automatically linked to the Help Station thread.

stable matrix
#

!s