consumer: Cannot connect to amqp://user:**@localhost:5672//: [Errno 111] Connection refused : <p>I am trying to build my airflow using docker and rabbitMQ. I am using rabbitmq:3-management image. And I am able to access rabbitMQ UI, and API.</p>

<p>In airflow I am building airflow webserver, airflow scheduler, airflow worker and airflow flower. Airflow.cfg file is used to config airflow.</p>

<p>Where I am using <code>broker_url = amqp://user:password@127.0.0.1:5672/</code> and  <code>celery_result_backend = amqp://user:password@127.0.0.1:5672/</code></p>

<p>My docker compose file is as follows</p>

<pre><code>version: '3'
services:
  rabbit1:
    image: "rabbitmq:3-management"
    hostname: "rabbit1"
    environment:
      RABBITMQ_ERLANG_COOKIE: "SWQOKODSQALRPCLNMEQG"
      RABBITMQ_DEFAULT_USER: "user"
      RABBITMQ_DEFAULT_PASS: "password"
      RABBITMQ_DEFAULT_VHOST: "/"
    ports:
      - "5672:5672"
      - "15672:15672"

    labels:
      NAME: "rabbitmq1"

  webserver:
    build: "airflow/"
    hostname: "webserver"
    restart: always
    environment:
      - EXECUTOR=Celery
    ports:
      - "8080:8080"
    depends_on:
      - rabbit1
    command:  webserver

  scheduler:
    build: "airflow/"
    hostname: "scheduler"
    restart: always
    environment:
      - EXECUTOR=Celery
    depends_on:
      - webserver
      - flower
      - worker
    command: scheduler

  worker:
    build: "airflow/"
    hostname: "worker"
    restart: always
    depends_on:
      - webserver
    environment:
      - EXECUTOR=Celery
    command: worker

  flower:
    build: "airflow/"
    hostname: "flower"
    restart: always
    environment:
      - EXECUTOR=Celery
    ports:
      - "5555:5555"
    depends_on:
      - rabbit1
      - webserver
      - worker
    command: flower
</code></pre>

<p>I am able to build images using docker compose. However, I am not able to connect my airflow scheduler to rabbitMQ. I am getting following error:</p>

<blockquote>
  <p>consumer: Cannot connect to amqp://user:**@localhost:5672//: [Errno
  111] Connection refused.</p>
</blockquote>

<p>I have tried using 127.0.0.1 and localhost both.</p>

<p>What I am doing wrong ?</p>
