Redis Connection Issue on Railway (ioredis)

3 months ago

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:yyBqSILlgwiYDnZOPgvQELaUAmvKLjgc@redis.railway.internal:6379

I'm using setting the REDIS_URL variable like this on railway: ${{Redis.REDIS_URL}}

I've read in similar threads that you should "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?

One thing to note is that my redis service is deployed in a US region while the backend is in europe. Ofc I'd want them both in Europe but its currently not an option on the hobby plan.

Thanks in advance!

Solved

9 Replies

3 months ago

Hello,

Could you please enable some more verbose logging?

With the current error message, there's not much I can help you with -

Error event - redisUrl: <redis_url>

Either way, even if you can't have Redis and your backend in the same EU region right now, you would still absolutely want to at least have them in the same region (Oregon) - the extra round trip time would absolutely kill performance for Redis actions.

Best,
Brody


Status changed to Awaiting User Response railway[bot] 3 months ago


3 months ago

Yes so from my understanding when we upgrade from the hobby plan, redis will be available in the EU region, but I haven't been able to find any specific information on this. Would you happen to know where I can find this information?

Here's some more error logging:



@mono/backend:start: Error: connect ETIMEDOUT

@mono/backend:start:     at TLSSocket.<anonymous> (/app/node_modules/ioredis/built/Redis.js:170:41)

@mono/backend:start:     at Object.onceWrapper (node:events:632:28)

@mono/backend:start:     at TLSSocket.emit (node:events:518:28)

@mono/backend:start:     at Socket._onTimeout (node:net:595:8)

@mono/backend:start:     at listOnTimeout (node:internal/timers:594:17)

@mono/backend:start:     at process.processTimers (node:internal/timers:529:7) {

@mono/backend:start:   errorno: 'ETIMEDOUT',

@mono/backend:start:   code: 'ETIMEDOUT',

@mono/backend:start:   syscall: 'connect'

@mono/backend:start: }

Status changed to Awaiting Railway Response railway[bot] 3 months ago


3 months ago

Yes users on the Pro plan will be able to move their Redis database deployed onto GCP (Non-Metal) into the EU West region.

For now, please move your app back to Oregon and let me know if that solves the issue.


Status changed to Awaiting User Response railway[bot] 3 months ago


3 months ago

I've move the backend to Oregon, and I'm still getting the same error.


Status changed to Awaiting Railway Response railway[bot] 3 months ago


3 months ago

Strangely, we have no other reports of this from other users, so I'm leaning more towards a configuration error here.

Are you able to provide us with a minimum reproducible code example here?


Status changed to Awaiting User Response railway[bot] 3 months ago


3 months ago

I can make a small copy of our repo yes. In the mean time, could you please explain how to "ensure V2 runtime enabled" ? Where can I find that setting.

Thanks again


Status changed to Awaiting Railway Response railway[bot] 3 months ago


3 months ago

If you don't see the runtime option in your service settings, V2 is already enabled.

Looking forward to that MRE!


Status changed to Awaiting User Response railway[bot] 3 months ago


3 months ago

I got it solved finally! Once I removed this, it started working:
```

tls: { rejectUnauthorized: false },
lazyConnect: true,

Status changed to Awaiting Railway Response railway[bot] 3 months ago


3 months ago

I'm glad you were able to solve it!


Status changed to Awaiting User Response railway[bot] 3 months ago


Status changed to Solved brody 3 months ago