Service cannot connect to Redis (ECONNREFUSED 127.0.0.1:6379) despite correct REDIS_URL

piggyride-sahalHOBBY

10 days ago

What we have tried and verified:

  • The Redis service is running and healthy (Ready to accept connections tcp in logs).

  • Both services are in the same Railway project/environment.

  • The service code uses process.env.REDIS_URL and validates the format.

  • The startup logs confirm that REDIS_URL is present and loaded.

  • We have redeployed the service after every change.

  • There is no .env file in the deployed container that could override the Railway variable.

  • We have restarted both the Redis and service containers.

  • The error persists: the service always tries to connect to 127.0.0.1:6379 instead of the internal Railway Redis host.

Solved$10 Bounty

7 Replies

10 days ago

This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.

Status changed to Open brody 10 days ago


lofimitHOBBY

10 days ago

Hello, would you be able to provide the code?
Does your code look like this: new Redis(process.env.REDIS_URL) ? If not, it should. If you do something like trying to splitting it into host/port or use the wrong constructor, it'll just default to localhost.
Also, can you add somehwere console.log("Redis URL:", process.env.REDIS_URL); and share the logs with us?
Thank you.


piggyride-sahalHOBBY

10 days ago

Thank you for your previous suggestion. I have updated my code & I have also added a debug log and confirmed in the logs that the value is: redis://REDISUSER:REDIS_PASSWORD@invigorating-laughter.railway.internal:6379 . (Password and host match what is shown in the Redis service “Connect” tab.) . However I am still getting error in the logs : error: Redis error: WRONGPASS invalid username-password pair or user is disabled.

I've copied the password directly from the Redis service “Connect” tab.

  • Verified the username is default.

  • Redeployed the service after every change.

  • Both services are in the same Railway project/environment.

  • No .env file is overriding the variable in production.

  • Tried both internal and public hostnames.

Attachments


piggyride-sahal

Thank you for your previous suggestion. I have updated my code & I have also added a debug log and confirmed in the logs that the value is: redis://REDISUSER:REDIS_PASSWORD@invigorating-laughter.railway.internal:6379 . (Password and host match what is shown in the Redis service “Connect” tab.) . However I am still getting error in the logs : error: Redis error: WRONGPASS invalid username-password pair or user is disabled.I've copied the password directly from the Redis service “Connect” tab.Verified the username is default.Redeployed the service after every change.Both services are in the same Railway project/environment.No .env file is overriding the variable in production.Tried both internal and public hostnames.

smolpawHOBBY

10 days ago

I think you might have misconfigured the redis or something has.
Could you download the railway cli : https://docs.railway.com/guides/cli
Then ssh into your redis service: https://blog.railway.com/p/ssh

Once you are there type redis-cli -a <your_password> to authenticate yourself. Because the problem here is your service is able to connect to redis but not able to authenticate. So you need to make sure you have the right credentials first.

Let me know if you need further help in any of these steps.


piggyride-sahalHOBBY

8 days ago

My redis deployment was incorrect.


smolpawHOBBY

8 days ago

tell us what was incorrect


piggyride-sahalHOBBY

8 days ago

I had deployed REDIS as a service & had manually added all the variables. It was not needed since railway provides a plugin for REDIS. Simply deleted the service & created new one using the plugin.


smolpawHOBBY

8 days ago

so i was correct about the misconfiguration.
I faced a similar thing where i wanted to deploy redis 8 to use the vector sets but the template only supported 7. At the end i ended up realizing i could deploy the template and change the version in settings, wipe the volume and redeploy.

this is why i asked you to check your credentials. the redis likely got initialized with a different password than the one you supplied later.


Status changed to Open chandrika 8 days ago


Status changed to Solved chandrika 8 days ago


Service cannot connect to Redis (ECONNREFUSED 127.0.0.1:6379) despite correct REDIS_URL - Railway Help Station