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
Project ID:
52b32c2c-e65f-443a-b59c-ba6a9bccf24c
No search results found.
⚠️ experimental feature
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 toThanks 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?
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
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•2y ago
Message Not Public
Sign In & Join Server To View
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."
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 thingstrue how do I change the password? Create new redis?
im not sure
not used it myself
Guess I'll just do that
Also this is how I added it in my app... I'm assuming this is right?
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 🤞)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"
are you able to post the logs and your code again plz
current attempt:
"Error -2 connecting to redis://default:**@containers-us-west-24.railway.app:6146. Name or service not known."
first attempt:
"Error -2 connecting to redis://default:*@containers-us-west-24.railway.app:6146:6379. Name or service not known"
* is where password was
try taking out redis//
no luck
currently here: "Error -2 connecting to default:*@containers-us-west-24.railway.app:6146. Name or service not known."
and without the username / pass you get authentication error right?
I've always had it in but I'll check
oh it looks like you pass them seperately
ig that would work
https://docs.redis.com/latest/rs/references/client_references/client_python/
In hostname should I pass REDISHOST or REDIS_URL?
try host
Worked! Hopefully no more issues, thank you so much.
nice
no worries