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
a year ago
do you have a 3 second sleep?
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?