Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

876
Visualizações
How to setup Django + RabbitMQ + Celery with Docker?

I'm trying to setup my Django app to have push notification functionality. For scheduling notifications I'm trying to use Celery, for the message broker I chose RabbitMQ. My app is running in Docker containers and I'm struggling to get the RabbitMQ to work. I get an error message Cannot connect to amqp://guest:**@127.0.0.1:5672//: [Errno 111] Connection refused. when running docker-compose up. Here are my celery and rabbitmq3 services from my docker-compose.yml:

celery:
    restart: always
    build:
      context: .
    command: celery -A test_celery worker -l info
    volumes:
      - .:/test_celery
    env_file:
      - ./.env
    depends_on:
      - app
      - rabbitmq3
  
rabbitmq3:
  container_name: "rabbitmq"
  image: rabbitmq:3-management-alpine
  ports:
    - 5672:5672
    - 15672:15672

In my test_celery -app I have a file called celery.py which contains the following:

import os
from celery import Celery

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'test_celery.settings')

app = Celery('test_celery')
app.config_from_object('django.conf:settings', namespace='CELERY')
app.autodiscover_tasks()

And finally, in my settings.py I have this: CELERY_BROKER_URL = 'amqp://localhost'.

Should I define the CELERY_BROKER_URL somehow different? Is there something wrong with my docker-compose file? Would appreciate any help with this, what is wrong with my setup?

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

this should do the trick

CELERY_BROKER_URL=amqp://guest:guest@rabbitmq3:5672/

if you have a vhost on rabbit

CELERY_BROKER_URL=amqp://guest:guest@rabbitmq3:5672/vhost

if it does not work check the console of the rabbit container for clues

over 4 years ago · Santiago Trujillo Relatório

0

In settings.py define:

RABBITMQ = {
    "PROTOCOL": "amqp", # in prod change with "amqps"
    "HOST": os.getenv("RABBITMQ_HOST", "localhost"),
    "PORT": os.getenv("RABBITMQ_PORT", 5672),
    "USER": os.getenv("RABBITMQ_USER", "guest"),
    "PASSWORD": os.getenv("RABBITMQ_PASSWORD", "guest"),
}

CELERY_BROKER_URL = f"{RABBITMQ['PROTOCOL']}://{RABBITMQ['USER']}:{RABBITMQ['PASSWORD']}@{RABBITMQ['HOST']}:{RABBITMQ['PORT']}"
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda