Celery in django project unable to connect to dockerized RabbitMQ in local development

  • everything runs on mac - i have an django project with celery running. I configured (as always) RabbitMQ as Broker and Redis as Result Backend. When i start the worker i get
[2022-11-18 11:53:56,256: ERROR/MainProcess] consumer: Cannot connect to amqp://guest:**@127.0.0.1:5672//: Server unexpectedly closed connection.
Trying again in 18.00 seconds... (9/100)

celery settings

CELERY_TIMEZONE = TIME_ZONE
CELERY_RESULT_BACKEND = "redis://localhost"
CELERY_BROKER_URL = "amqp://localhost"

docker-compose.yaml

version: "3.8"

services:
  db:
    image: postgres:14
    ports:
      - "5432:5432"
    environment:
      - POSTGRES_DB=local
      - POSTGRES_USER=test_user
      - POSTGRES_PASSWORD=test_test1!
    volumes:
      - db-data:/var/lib/postgresql/data
  redis:
    image: redis
    ports:
      - "6379:6379"
    volumes:
      - redis-data:/data
  rabbitmq:
    image: rabbitmq:management
    ports:
      - "5672:5762"
      - "15672:15672"

volumes:
  db-data:
  redis-data:

Connecting to the Management panel with base guest:guest works fine, but celery can't connect.

Expecting that celery can connect to rabbitmq and no connection gets closed

Found a typo - mapped RabbitMQ from 5672 to 5762.. can be closed

Back to Top