stockotaco
PROOP
8 months ago
I am having the hardest time trying to connect to Redis for some reason.
I continue to get ENOTFOUND even with family=0 parameter.
5 Replies
Here is the code I am using to just test this:
const redisUrl = process.env.REDIS_URL;
console.log('Attempting to connect to Redis with URL:', redisUrl?.replace(/:[^:@]+@/, ':****@'));
// Initialize Redis client with REDIS_URL and family=0 for dual stack lookup
const redis = new Redis(process.env.REDIS_URL + '?family=0', {
tls: {
rejectUnauthorized: false
},
connectTimeout: 10000, // 10 seconds
retryStrategy: (times) => {
const delay = Math.min(times * 50, 2000);
console.log(`Retrying Redis connection attempt ${times} with delay ${delay}ms`);
return delay;
}
});I always get this error:
Redis connection error: Error: connect ETIMEDOUT
at TLSSocket. (/app/node_modules/ioredis/built/Redis.js:170:41)
at Object.onceWrapper (node:events:631:28)
at TLSSocket.emit (node:events:517:28)
at Socket._onTimeout (node:net:598:8)
at listOnTimeout (node:internal/timers:569:17)
at process.processTimers (node:internal/timers:512:7) {
errorno: 'ETIMEDOUT',
code: 'ETIMEDOUT',
syscall: 'connect'
}
Error details: {
code: 'ETIMEDOUT',
errno: undefined,
syscall: 'connect',
message: 'connect ETIMEDOUT'
}brody
EMPLOYEE
8 months ago
perhaps you are using an older version of ioredis that lacks IPv6 support outright?
phoenixauro
HOBBY
8 months ago
Where are you running the test code?
If it is locally you need to use a public url for redis. REDIS_URL gives the internal url.
In case you are running it from within Railway check https://docs.railway.com/dynamic/reference/errors/enotfound-redis-railway-internal

