Cannot connect to Redis via Private Network
jtourkos
PROOP

2 years ago

In my nodejs app I create a BeeQueue instance like:

const eventProcessingQueue = new BeeQueue(`queue_name`, {
  redis: { url: appSettings.redisConnectionString },
});

appSettings.redisConnectionString is set - correctly - to the internal Redis URL, but when trying to deploy (after successfully building),

I get Redis connection to redis.railway.internal:6379 failed - getaddrinfo ENOTFOUND redis.railway.internal.

Switching to the public URL, works fine.

Tried appending family=6 (and 0 which is the default) at the connection string.

Also tried creating a redis client and seting the socket family to 6 but then it fails for another reason (trying to connect to localhost).

I also have setup a sleep when starting.

The service I'm connecting from and the redis instance, both are in the same project.

Any ideas?

Thank you!

Solved

29 Replies

jtourkos
PROOP

2 years ago

N/A


2 years ago

please read this docs section -


2 years ago

you might not be directly using ioredis, but more than likely it's what beequeue is using under the hood


jtourkos
PROOP

2 years ago

Hi @Brody 👋

I already tried that, still the same issue. Beequeue uses https://github.com/redis/node-redis.


2 years ago

does it use some very old version of that module? perhaps before it supported ipv6


jtourkos
PROOP

2 years ago

If you check here https://github.com/redis/node-redis/blob/master/docs/client-configuration.md I also tried setting socket.family to 6


2 years ago

okay fair, are you getting these errors locally on when on Railway


jtourkos
PROOP

2 years ago

The only difference is that when I try something like

const redisClient = createClient({
      url: appSettings.redisConnectionString,
      socket: {
        family: 6,
      },
    });

i now get the same error but it tries to connect to localhost


2 years ago

that just means that's incorrect syntax and the client is falling back to it's default values for the host


2 years ago

?


jtourkos
PROOP

2 years ago

on Railway after building while deploying


2 years ago

is redis in the same project?


jtourkos
PROOP

2 years ago

yeah


2 years ago

are you pro?


jtourkos
PROOP

2 years ago

yup


2 years ago

can you try switching to the v2 runtime in the service settings


jtourkos
PROOP

2 years ago

where is that?


2 years ago

in the service settings


jtourkos
PROOP

2 years ago

i don't see such a setting 🤔


2 years ago


jtourkos
PROOP

2 years ago

Yeah, i know where the service settings are, I just don't find something to switch to v2 🙂


2 years ago

oh my bad, sorry for assuming


jtourkos
PROOP

2 years ago

no worries 🙂


2 years ago

let me get back to you when I'm at my computer, might end up needing a minimal reproducible example


jtourkos
PROOP

2 years ago

Alright, thanks!


2 years ago

and I'll need a project id for that


tansandoteth
PRO

a year ago

Did you resolve this? I am having the same issue and can't seem to find a solution other than using the public url


tansandoteth
PRO

a year ago

I found this combination worked for me with redis 4.7.0

  const redisClient = createClient({
    url: Deno.env.get("REDIS_URL"), // https://docs.railway.com/reference/errors/enotfound-redis-railway-internal
    socket: {
      family: 6,
    },
  });

7 months ago

i have the same problem


Status changed to Solved brody 7 months ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...