Skip to content
Celery connection issue
Anonymous
OP

3 years ago

Hi! Just recently I've been having issues with my celery instance. It was working all this time. It can't connect to redis (everything is dockerized). Here is the following issue: Cannot connect to {redacted redis address} Lookup timed out.. - Has anyone had the same issue?

Closed

102 Replies

Anonymous
OP

3 years ago

N/A


3 years ago

the redis address would be very important to help us debug this


Anonymous
OP

3 years ago

redis-15409.c281.us-east-1-2.ec2.cloud.redislabs.com:15409


Anonymous
OP

3 years ago

🙂


3 years ago

oh so not on railway


3 years ago

is there some kind of whitelist you need to do?


Anonymous
OP

3 years ago

well I also tried railway as well


Anonymous
OP

3 years ago

I'm having the same issue no matter the redis address


Anonymous
OP

3 years ago

however it works just fine when connecting locally


3 years ago

can we focus on getting you connected to a railway hosted redis database?


Anonymous
OP

3 years ago

local instance to production redis


Anonymous
OP

3 years ago

that's dine with me


Anonymous
OP

3 years ago

fine*


3 years ago

works better for me since i know nothing about redislabs


Anonymous
OP

3 years ago

monorail.proxy.rlwy.net:34378


3 years ago

can i see a screenshot of your railway project please?


Anonymous
OP

3 years ago

sure


Anonymous
OP

3 years ago

give me a sec, let me configure redis on railway


3 years ago

if redis isn't configured, where did you get that domain from?


Anonymous
OP

3 years ago

so that domain is from a heroku instance, I'm having the same issue and decided to try railway to see if it was a isolated instance


Anonymous
OP

3 years ago

My application had been working just fine up until today


3 years ago

im talking about this domain


Anonymous
OP

3 years ago

Oh I had tested a setup


Anonymous
OP

3 years ago

earlier


Anonymous
OP

3 years ago

I just tried connecting to it and i do get the same error


Anonymous
OP

3 years ago

[2024-02-26 17:31:11,560: ERROR/MainProcess] consumer: Cannot connect to redis://default:**@monorail.proxy.rlwy.net:34378/0: Error -3 connecting to monorail.proxy.rlwy.net:34378. Lookup timed out..


3 years ago

please show me the screenshot of your project


Anonymous
OP

3 years ago

just a normal screenshot? or is there a railway function


Anonymous
OP

3 years ago

sorry, new to this


Anonymous
OP

3 years ago

(no markdown available for this content)


Anonymous
OP

3 years ago

ignore the flask


3 years ago

okay can show me how you are trying to connect to it


Anonymous
OP

3 years ago

let me make a quick loom



Anonymous
OP

3 years ago

Thanks for the help!


Anonymous
OP

3 years ago

I truly appreciate it


3 years ago

very helpful video, what do you have REDIS_ENDPOINT and REDIS_PORT set to in your service variables?


Anonymous
OP

3 years ago

give me one sec


Anonymous
OP

3 years ago

REDIS_ENDPOINT=default:**@monorail.proxy.rlwy.net

REDIS_PORT=34378


Anonymous
OP

3 years ago

asterisk is the password btw


3 years ago

instead of trying to build the url yourself, just use a REDIS_URL variable in the celery config file, then in your service variables set REDIS_URL to ${{Redis.REDIS_PRIVATE_URL}}

this is unlikely to fix the main issue, but its best we do this instead


Anonymous
OP

3 years ago

okay got it - would my config look like this then?

import os

from dotenv import load_dotenv

load_dotenv()

REDIS_URL = os.environ.get('REDIS_URL', '6379') # default to 6379 if not provided

imports = ["tasks"]

broker_url = REDIS_URL

result_backend = REDIS_URL

task_serializer = 'json'

result_serializer = 'json'

accept_content = ['json']

timezone = 'America/Chicago'

enable_utc = True

broker_connection_retry_on_startup = True


3 years ago

lets omit the dotenv for now, since it looks like you are committing that file to your repo


Anonymous
OP

3 years ago

okay gotcha


3 years ago

import os

imports = ["tasks"]

broker_url = os.environ['REDIS_URL']
result_backend = os.environ['REDIS_URL']
task_serializer = 'json'
result_serializer = 'json'
accept_content = ['json']
timezone = 'America/Chicago'
enable_utc = True
broker_connection_retry_on_startup = True

Anonymous
OP

3 years ago

oaky got it - railway gives me two options REDIS_URL and REDIS_PRIVATE_URL


Anonymous
OP

3 years ago

when I'm setting env varible


3 years ago

please reference my message


Anonymous
OP

3 years ago

okay got it, deploying now


Anonymous
OP

3 years ago

okay deployed -s ame issue


3 years ago

show me the new error please


Anonymous
OP

3 years ago

[2024-02-26 17:54:49,592: ERROR/MainProcess] consumer: Cannot connect to redis://default:**@redis.railway.internal:6379//: Error -3 connecting to redis.railway.internal:6379. Lookup timed out..


3 years ago

cool, send your dockerfile please, and going forward please enclose logs and code (or similar) in code blocks


Anonymous
OP

3 years ago

sorry haha , how do i enclose in code blocks


3 years ago

triple backticks


Anonymous
OP

3 years ago

(no markdown available for this content)


3 years ago

try this instead

# Dockerfile.worker

# Use an official Python runtime as a parent image
FROM python:3.11.1

WORKDIR /app

COPY requirements.txt .
RUN pip install -r requirements.txt

COPY . .

# Command to run the Celery worker
CMD sleep 3 && celery -A tasks worker --loglevel=info --pool=eventlet

Anonymous
OP

3 years ago

trying


Anonymous
OP

3 years ago

same issue


3 years ago

interesting


Anonymous
OP

3 years ago

yeah, I'm not sure if it's a rediscloud issue but status have been okay with a few urgent fixes that happend last two days


Anonymous
OP

3 years ago

as I said before, everything worked properly until today


Anonymous
OP

3 years ago

does railway use the rediscloud service?


3 years ago

railway deploys a redis docker image


Anonymous
OP

3 years ago

hmm.


Anonymous
OP

3 years ago

yeah, it's really odd


Anonymous
OP

3 years ago

driving me insane


3 years ago

increase the sleep to 10 seconds?


Anonymous
OP

3 years ago

sure ill try it


Anonymous
OP

3 years ago

same issue :/


3 years ago

im kinda out of ideas, you sure you are usng the dockerfile i provided?


Anonymous
OP

3 years ago

Yes I am :9


Anonymous
OP

3 years ago

😦


Anonymous
OP

3 years ago

I'm dumbfounded as well. It literally worked for months before today


3 years ago

and you haven't modified anything at all about the redis database on railway right? absolutely nothing at all?


Anonymous
OP

3 years ago

Nope


Anonymous
OP

3 years ago

nothing


Anonymous
OP

3 years ago

I even tried rabbitmq instead of redis


Anonymous
OP

3 years ago

same issue


3 years ago

let me do some thinking, could you share your repo, or add me to it?


Anonymous
OP

3 years ago

Thank you! This is under a client repo but I can create another and add you in


3 years ago

yes please

brody192


Anonymous
OP

3 years ago

Hmm


Anonymous
OP

3 years ago

well, here's another thing


Anonymous
OP

3 years ago

I tried a skeleton celery


Anonymous
OP

3 years ago

and it's connecting


Anonymous
OP

3 years ago

I'm going to look into this further


Anonymous
OP

3 years ago

I'll keep you posted 🙂


Anonymous
OP

3 years ago

Thank you Brody


Anonymous
OP

3 years ago

I will definitley buy you some coffee


3 years ago

theres no need but i very much appreciate the gesture


Anonymous
OP

3 years ago

Here you go ! https://www.buymeacoffee.com/brody192/c/8635280 - The world needs mroe people like you. Much appreciated


Anonymous
OP

3 years ago

I figured out what it was - it was the concurrency pool. Eventlet doesn't want to play nice with Docker I guess


3 years ago

sorry i couldn’t solve this but happy you have! and thank you so much for the train!!


3 years ago

a sleep is still needed, but you can bump the sleep down to 3 seconds


Anonymous
OP

3 years ago

Okay sounds good! Why do you recommend the sleep?


Anonymous
OP

3 years ago

You still helped, I appreciate it


3 years ago

because the private network takes about 3 seconds to be able to respond to dns lookups


Anonymous
OP

3 years ago

Ah okay gotcha


Anonymous
OP

3 years ago

makes sense


Anonymous
OP

3 years ago

thank you again


3 years ago

happy to help where i can!


Welcome!

Sign in to your Railway account to join the conversation.

Loading...