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?