Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

875
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda