Celery + Django + Redis - error: [Errno 111] Connection refused
<p>I have an API app running Django. I have 2 containers,</p>

<pre><code>CONTAINER ID        IMAGE                   COMMAND             CREATED             STATUS                     PORTS                    NAMES
5620d232e96c        django_worker:v1   "/bin/bash"         4 days ago          Up 4 days                                           drunk_goldberg
eeb5b0e8dbce        django_main:v1     "./main.sh"         4 days ago          Up 4 days                  0.0.0.0:8000-&gt;8000/tcp   sick_almeida
</code></pre>

<p>Both host the same code base. The main is exposing the API, The other is running the <strong>celery worker</strong> via the command,</p>

<pre><code>su -m celery -c "celery --app=XXX.celery:app worker -Q ${QUEUE} --loglevel=INFO --autoscale=10,3"
</code></pre>

<p>The <strong>Django settings</strong> file in both containers is,</p>

<pre><code>BROKER_URL = 'redis://10.1.1.8:6379/0'
CELERY_ACCEPT_CONTENT = ['json']
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
</code></pre>

<p>However in the <strong>main</strong> container i get the error,</p>

<pre><code>ERROR:XXX.views:Exception Raised:
Traceback (most recent call last):
  File "/opt/XXX/XXX/views.py", line 169, in upgrade
    ABC.delay(username,password,ip,device,manifest,peer_ip)
  File "/usr/local/lib/python2.7/dist-packages/celery/app/task.py", line 453, in delay
    return self.apply_async(args, kwargs)
  File "/usr/local/lib/python2.7/dist-packages/celery/app/task.py", line 560, in apply_async
    **dict(self._get_exec_options(), **options)
  File "/usr/local/lib/python2.7/dist-packages/celery/app/base.py", line 354, in send_task
    reply_to=reply_to or self.oid, **options
  File "/usr/local/lib/python2.7/dist-packages/celery/app/amqp.py", line 305, in publish_task
    **kwargs
  File "/usr/local/lib/python2.7/dist-packages/kombu/messaging.py", line 172, in publish
    routing_key, mandatory, immediate, exchange, declare)
  File "/usr/local/lib/python2.7/dist-packages/kombu/connection.py", line 457, in _ensured
    interval_max)
  File "/usr/local/lib/python2.7/dist-packages/kombu/connection.py", line 369, in ensure_connection
    interval_start, interval_step, interval_max, callback)
  File "/usr/local/lib/python2.7/dist-packages/kombu/utils/__init__.py", line 243, in retry_over_time
    return fun(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/kombu/connection.py", line 237, in connect
    return self.connection
  File "/usr/local/lib/python2.7/dist-packages/kombu/connection.py", line 741, in connection
    self._connection = self._establish_connection()
  File "/usr/local/lib/python2.7/dist-packages/kombu/connection.py", line 696, in _establish_connection
    conn = self.transport.establish_connection()
  File "/usr/local/lib/python2.7/dist-packages/kombu/transport/pyamqp.py", line 116, in establish_connection
    conn = self.Connection(**opts)
  File "/usr/local/lib/python2.7/dist-packages/amqp/connection.py", line 165, in __init__
    self.transport = self.Transport(host, connect_timeout, ssl)
  File "/usr/local/lib/python2.7/dist-packages/amqp/connection.py", line 186, in Transport
    return create_transport(host, connect_timeout, ssl)
  File "/usr/local/lib/python2.7/dist-packages/amqp/transport.py", line 299, in create_transport
    return TCPTransport(host, connect_timeout)
  File "/usr/local/lib/python2.7/dist-packages/amqp/transport.py", line 95, in __init__
    raise socket.error(last_err)
error: [Errno 111] Connection refused
</code></pre>

<p>Now if I test the connection from the main container its fine.</p>

<p>Any ideas ?</p>