Redis Connection Refused

I am trying to deploy a Flask app with Redis but am getting the following error: "Error 111 connecting to 127.0.0.1:6379. Connection refused." I have tried to figure this out through forums online but as a beginner I'm finding it very difficult to know what steps apply to me. I'm sure I'm missing something basic. Any help is greatly appreciated. Project ID: 52b32c2c-e65f-443a-b59c-ba6a9bccf24c
31 Replies
Percy
Percy2y ago
Project ID: 52b32c2c-e65f-443a-b59c-ba6a9bccf24c
Percy
Percy2y ago
No search results found.
⚠️ experimental feature
Finn
Finn2y ago
If your connecting to redis. The 127.0.01:6379 is the part that need changing. Replace this with the redis connection URL ( this probally can be found via the railway ui ) asuming your hosting redis on railway to
Weatherman
WeathermanOP2y ago
Thanks for you reply. I'm not able to find the url, not sure what you mean by via railway ui. Also I came across this page: https://docs.railway.app/databases/redis should I be supplying these variables?
Railway Docs
Redis | Railway Docs
Documentation for Railway
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Weatherman
WeathermanOP2y ago
Sorry I'm not seeing a connect tab - checked in the project page and in settings. Could you please point me to it? Or could I just do this in the variables tab.
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Weatherman
WeathermanOP2y ago
Ok I added the url to my app but now I'm getting this error: "Error -2 connecting to redis://default:[email protected]:6835. Name or service not known."
Finn
Finn2y ago
yeah your going to want to rotate your password now. the connection url you just pasted contains a username and password needed to connect to redis default:sUOkdTSrwlMVuWMMDFEf tbh it would not suprise me if there were userbots on this discord that scrape for these kind of things
Weatherman
WeathermanOP2y ago
true how do I change the password? Create new redis?
Finn
Finn2y ago
im not sure not used it myself
Weatherman
WeathermanOP2y ago
Guess I'll just do that Also this is how I added it in my app... I'm assuming this is right?
Weatherman
WeathermanOP2y ago
Finn
Finn2y ago
ah so if your using a railway redis instance the password should be injected automatically into your process'es eviroment variables. so you should just change the string for this: ( 1 sec ) os.getenv('REDIS_URL') ( hopefully that shoudl work 🤞)
Weatherman
WeathermanOP2y ago
Tried that and same error but this time for some reason the error log showed the url with port 6379 (the Redis default I think) appended to it, so the ending was ".app:6146:6379." In this case I did not have port argument from the screenshot. I then added the port argument but got the error again, this time with the ending ".app:6146:6146" Now I've tried to get the 3 variables into a string excluding the port and kept the port argument, same error but now the ending is just ".app:6146"
Finn
Finn2y ago
are you able to post the logs and your code again plz
Weatherman
WeathermanOP2y ago
current attempt: "Error -2 connecting to redis://default:**@containers-us-west-24.railway.app:6146. Name or service not known."
Weatherman
WeathermanOP2y ago
Weatherman
WeathermanOP2y ago
first attempt: "Error -2 connecting to redis://default:*@containers-us-west-24.railway.app:6146:6379. Name or service not known"
Weatherman
WeathermanOP2y ago
Weatherman
WeathermanOP2y ago
* is where password was
Finn
Finn2y ago
try taking out redis//
Weatherman
WeathermanOP2y ago
no luck currently here: "Error -2 connecting to default:*@containers-us-west-24.railway.app:6146. Name or service not known."
Finn
Finn2y ago
and without the username / pass you get authentication error right?
Weatherman
WeathermanOP2y ago
Weatherman
WeathermanOP2y ago
I've always had it in but I'll check
Finn
Finn2y ago
oh it looks like you pass them seperately
redis.Redis(
host='hostname',
port=port,
password='password')
redis.Redis(
host='hostname',
port=port,
password='password')
ig that would work https://docs.redis.com/latest/rs/references/client_references/client_python/
Weatherman
WeathermanOP2y ago
In hostname should I pass REDISHOST or REDIS_URL?
Finn
Finn2y ago
try host
Weatherman
WeathermanOP2y ago
Worked! Hopefully no more issues, thank you so much.
Finn
Finn2y ago
nice no worries
Want results from more Discord servers?
Add your server