Can't connect to Redis
stockotaco
PROOP

a year ago

$10 Bounty

5 Replies

stockotaco
PROOP

a year ago

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;
  }
});

stockotaco
PROOP

a year ago

Service variables:

1384405544193888256


stockotaco
PROOP

a year ago

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'

}

a year ago

perhaps you are using an older version of ioredis that lacks IPv6 support outright?


phoenixauro
HOBBY

a year 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


Welcome!

Sign in to your Railway account to join the conversation.

Loading...