Can't connect to redis internal but can over ipv4 addr

nxfi777PRO

a year ago

I am trying to use the railway internal network for a Redis store in a NodeJS server but I can only connect using the external ipv4 address. Here is the JS connection logic:

const redisClient = createClient({ url: process.env.REDIS_URL });
await redisClient.connect();

REDIS_URL is a service variable defined in the NodeJS service.

ipv4 address:redis://default:(password here)@[viaduct.proxy.rlwy.net:27261](viaduct.proxy.rlwy.net:27261)
ipv6 address:redis://default:(password here)@redis.railway.internal:6379

I have also tried redis://default:(password here)@redis:6379 as this is valid schema.

Error Log:

node:internal/process/promises:289

triggerUncaughtException(err, true /* fromPromise */);

^

Error: getaddrinfo ENOTFOUND redis

at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:dns:118:26)

Emitted 'error' event on Commander instance at:

at RedisSocket. (/usr/src/app/node_modules/@redis/client/dist/lib/client/index.js:412:14)

at RedisSocket.emit (node:events:519:28)

at RedisSocket._RedisSocket_connect (/usr/src/app/node_modules/@redis/client/dist/lib/client/socket.js:166:18)

at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

at async Commander.connect (/usr/src/app/node_modules/@redis/client/dist/lib/client/index.js:185:9)

at async /usr/src/app/index.js:38:3 {

errno: -3008,

code: 'ENOTFOUND',

syscall: 'getaddrinfo',

hostname: 'redis'

}

Node.js v21.7.1

1 Replies

nxfi777PRO

a year ago

b88cd4f4-3e33-4c82-8bb1-90877719ae87


nxfi777PRO

a year ago

@Brody any ideas?


a year ago

do you have a 3 second sleep?


nxfi777PRO

a year ago

I do not


nxfi777PRO

a year ago

could you elaborate


nxfi777PRO

a year ago

I only connect to redis via a specific endpoint, its not instant


nxfi777PRO

a year ago

so the delayed internal start isnt the issue here


nxfi777PRO

a year ago

(probably)


a year ago


sydalihsnPRO

10 months ago

@nxfi777 I'm also facing the same issue. Seems like the REDIS_URL is undefined even though it's set in the project variables. How did you fix it?