R
Railway

✋|help

Redis not configured properly for Django

Iiceman42309/4/2023
Hi, I'm trying to use Redis with Django and Channels. I keep getting this error message which seems to be suggesting that Redis isn't configured for running redis-py commands.

I've tried to change the channel layer settings and not got anywhere. I don't know whether I'm supposed to be adding some sort of default setting for Redis itself. - got no idea why it's trying to connect to localhost. Anyone have any idea how to fix this?

r.hset(self.scope['user'].username, mapping={'channel' : self.channel_name})
File "/opt/venv/lib/python3.11/site-packages/redis/commands/core.py", line 5019, in hset
return self.execute_command("HSET", name, *items)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/venv/lib/python3.11/site-packages/redis/client.py", line 505, in execute_command
conn = self.connection or pool.get_connection(command_name, **options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/venv/lib/python3.11/site-packages/redis/connection.py", line 1073, in get_connection
connection.connect()
File "/opt/venv/lib/python3.11/site-packages/redis/connection.py", line 265, in connect
raise ConnectionError(self._error_message(e))
redis.exceptions.ConnectionError: Error 111 connecting to localhost:6379. Connection refused.
Iiceman42309/4/2023
N/A
Bbrody1929/4/2023
show a screenshot of your service variables please
Iiceman42309/4/2023
Bbrody1929/4/2023
and show me the code that connects to the redis database please
Iiceman42309/4/2023
There's a lot but it's currently failing when it tries to cache the username and channel
Bbrody1929/4/2023
I don't see anywhere in that code that it's using environment variables, you aren't even importing os to read any environment variables
Iiceman42309/4/2023
I ran all this locally and it worked
is it supposed to be set up like this on the server: r = redis.Redis(host='localhost', port=6379, decode_responses=True)
Bbrody1929/4/2023
yes but now you are on railway, you need to use the railway provided environment variables, otherwise you are just trying to connect to localhost
Iiceman42309/4/2023
Okay, got it working. Thanks for the pointers!
Bbrody1929/4/2023
no problem!

Looking for more? Join the community!

Recommended Posts
Inspecting built Docker Image locallyHello I have an issue in my application when running in Railway. I would like to download the image Is there someway for me to choose a custom range in the observability?docker flask shows Application failed to respondRepo: https://github.com/chamuditha4/flask1 URL : https://flask-production-7492.up.railway.app/ prGetting 503 Server Error during load testsI'm load testing a simple fastapi backend running on railway. Using locust for load testing with 100Ideal way to compose and manage a full stack app?Railway doesn't really seem to be exposing an example of how one could/should compose a full stack aUsage estimatesSo im trying to make a simple project using a MySQL database and im trying to figure out how much itMy website is not running due to SSL supportThe browser is showing following message: alfajr.edu.pk uses an unsupported protocol. ERR_SSL_VERSIPricing/resource questionHere's a silly question, how should I decide on what plan to use for hosting? I'm pretty dumb at thiAny solution for Typebot 2.17? Still showing server errorAPI response timeHello! I am looking for the best place to deploy my API and I currently have the "Pro Plan" package.Added a template as CRON service and it shows "Your project has no deploys"I added this template to take automatic DB backup - https://railway.app/template/UGKaB8 I added a Cservice in only one environment?Is it possible to have certain service(s) only in specific environment? I am making a new cron job tdeploy not building uptried it already three times now canceled teh ones before at around 5 mins the third is currently atError connecting to Redis database.As shown in the picture, I cannot connect to the database. I do not know the reason, but I think thaLove Railway but confused on pricingHello! I’m currently using the free trial of Railway for a service, and I’m loving it. As my free trWhat I thought was a simple python upgrade broke my deployed flask service. Need some help.Project ID: b06af9f3-d9c9-4d4c-a74f-c5521f149984/service/872870dd-f98a-486c-9f14-09fcd5bc43e5Question regarding pausing subscriptionHi there! I’m relatively new to railway, I’ve registered before the pricing change and got verifiedError with discord bot using go and pythonI am new to asking questions in a place like this, so please forgive me if there are any problems ISelenium driver unable to fetch page in Selenium deploymentI am facing an issue while deploying my app via railway.app. 

Here is the description of the app: I up loaded Tesseract-OCR Folder on gitup but on railway cant't findpytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it's not in your PATH.