Unable to connect to Redis via CLI: getaddrinfo ENOTFOUND redis.railway.internal
Anonymous
TRIALOP

a year ago

I have deployed a fresh instance of MedusaJS 2.0 on railway following all the steps and I'm struggling to connect to Redis via the CLI.

The build has succeeded and I can open the app in the browser. Migrations have run correctly too during the build.

When I try to run:

railway run npx medusa user -e email@email.com -p password

in the command line after connecting to the railway project, I am getting the following error:

[ioredis] Unhandled error event: Error: getaddrinfo ENOTFOUND redis.railway.internal
    at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:dns:120:26)
error:   An error occurred while connecting to Redis in module 'cache-redis': Error: Connection is closed.
[ioredis] Unhandled error event: Error: getaddrinfo ENOTFOUND redis.railway.internal
    at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:dns:120:26)
info:    Connection to Redis in module 'event-bus-redis' established
Error: Connection is closed.

I raised this issue on MedusaJS Github and was told it sounds like a misconfiguration or that the Redis service is down.

I have checked over my config and I can't see the problem. The Redis URL variable is set to the following which I believe is correct:

${{Redis.REDIS_URL}}?family=0

I have also tried restarting the service to see if there was something wrong there but I am still getting the issue.

Link to github issue (with full logs as reached character limit): https://github.com/medusajs/medusa/issues/10494

Link to github repo with code: https://github.com/XigeTime/solstice-medusa-app

Project ID & link is: https://railway.app/project/d425ed0c-e0a5-4d20-a95b-9a69c0201f38 (I can't seem to add it below)

Thanks, any help is much appreciated!

Solved

3 Replies

brody
EMPLOYEE

a year ago

When running commands locally with railway run you must use the public host and port of the database your app connects to.


Anonymous
TRIALOP

a year ago

Thanks Brody, managed to figure out I needed to use the public hosts for both Postgres and Redis when running the CLI. I'm assuming due to the egress costs it's not recommended to use leave these in the environment variables when done with the CLI - is it possible to overwrite the variable when using the command railway run instead of updating the environment variables each time?

Thanks


brody
EMPLOYEE

a year ago

You could have both public and private variables in parallel, and do a simple in code check to detect if you're running in production on Railway, or developing locally. Then use the applicable variable for the environment.


Status changed to Solved brody 12 months ago


Loading...