Service can't connect privately to redis

vkoukHOBBY

9 months ago

Hello all i am trying to deploy a service (nestjs) and connect privately to redis through bullmq

This is the way i am trying to connect to it

BullModule.forRootAsync({
    imports: [ConfigModule],
    useFactory: (configService: ConfigService) => ({
        url: configService.get<string>("REDIS_URL"),
    }),
    inject: [ConfigService],
}),

It only works with the public network url not with private.

The error i get: MaxRetriesPerRequestError: Reached the max retries per request limit (which is 20). Refer to "maxRetriesPerRequest" option for details.

Solved

7 Replies

9 months ago

IIRC bullmq uses ioredis internally, if so, please read this docs page -

https://docs.railway.app/guides/private-networking#known-configuration-requirements-for-ipv6


vkoukHOBBY

9 months ago

It does, although why it works for public and privste networking? What do i have to configure?


9 months ago

The private network is IPv6 and the public network is IPv4, please read the docs page I linked for an explanation on why that matters in this context.


vkoukHOBBY

9 months ago

I tried adding the family option as is described

BullModule.forRootAsync({
    imports: [ConfigModule],
    useFactory: (configService: ConfigService) => ({
        redis: {
            host: configService.get<string>("REDIS_HOST"),
            username: configService.get<string>("REDIS_USERNAME"),
            password: configService.get<string>("REDIS_PSWD"),
            port: Number(configService.get<string>("REDIS_PORT")),
            family: 0,
        },
    }),
    inject: [ConfigService],
}),

No chance

9 months ago

Is your service on the V2 runtime? check in the service settings.


vkoukHOBBY

9 months ago

Oh i found the issue. I had the tls config which didn't like it for private ip and this is accepted.. Problem solved


9 months ago

Awsome! family: 0 is still needed though, so be sure not to remove that.


Status changed to Solved brody 9 months ago


Service can't connect privately to redis - Railway Help Station