AMQP connection reset by peer, but celery connected
<p>I have a flask app using Celery with RabbitMQ as the broker.</p>

<p>I've followed the instructions in this <a href="https://stackoverflow.com/questions/26986746/how-to-configure-and-run-celery-worker-on-remote-system">answer</a> to get started.</p>

<p>I have two machines.</p>

<p>Machine A, where RabbitMQ runs, sends tasks to be consumed by celery on Machine B.</p>

<p>My Broker Url and Backend Result Url are the same: <code>amqp://remote:***@12.345.678.999:5672/remote_host</code>.</p>

<p>Both machines have copies of the flask app on them. RabbitMQ has been configured so that user remote has all permissions granted ".* .* .*". All the communication between RabbitMQ and Celery works fine when they're both running on localhost on Machine A.</p>

<p>I start celery on Machine B with <code>celery worker -l info -A app.celery</code>, and everything looks fine:</p>

<pre><code> -------------- celery@ip-XXX-XX-XX-XXX v4.0.0 (latentcall)
---- **** ----- 
--- * ***  * -- Linux-4.4.0-45-generic-x86_64-with-Ubuntu-16.04-    xenial 2016-11-06 18:18:01
-- * - **** --- 
- ** ---------- [config]
- ** ---------- .&gt; app:         app:0x7f5b9dd73d90
- ** ---------- .&gt; transport:   amqp://remote:**@12.345.578.999:5672/remote_host
- ** ---------- .&gt; results:     amqp://
- *** --- * --- .&gt; concurrency: 1 (prefork)
-- ******* ---- .&gt; task events: OFF (enable -E to monitor tasks in this worker)
--- ***** ----- 
 -------------- [queues]
            .&gt; celery           exchange=celery(direct) key=celery


[tasks]
  . app.views.task1
  . app.views.task2
  . app.views.task3


[2016-11-06 18:18:01,614: INFO/MainProcess] Connected to amqp://remote:**@12.345.678.999:5672/remote_host
[2016-11-06 18:18:01,627: INFO/MainProcess] mingle: searching for neighbors
[2016-11-06 18:18:02,658: INFO/MainProcess] mingle: all alone
[2016-11-06 18:18:02,672: INFO/MainProcess] celery@ip-XXX-XX-XX-XXX ready.
</code></pre>

<p>When I run the app on Machine A and try to send a task through RabbitMQ to Celery, I get <code>[Errno 104] Connection reset by peer</code> with the following (partial) stack trace:</p>

<pre><code>  File "/home/ubuntu/app/env/local/lib/python2.7/site-packages/amqp/abstract_channel.py", line 67, in wait
self.channel_id, allowed_methods, timeout)
  File "/home/ubuntu/app/env/local/lib/python2.7/site-packages/amqp/connection.py", line 241, in _wait_method
channel, method_sig, args, content = read_timeout(timeout)
  File "/home/ubuntu/app/env/local/lib/python2.7/site-packages/amqp/connection.py", line 330, in read_timeout
return self.method_reader.read_method()
  File "/home/ubuntu/app/env/local/lib/python2.7/site-packages/amqp/method_framing.py", line 189, in read_method
raise m
error: [Errno 104] Connection reset by peer
</code></pre>

<p>I also get an AMQP debug statemenet like the following:</p>

<pre><code>amqp: DEBUG: Start from server, version: 0.9, properties:    {u'information': u'Licensed under the MPL.  See   http://www.rabbitmq.com/', u'product': u'RabbitMQ', u'copyright':    u'Copyright (C) 2007-2015 Pivotal Software, Inc.', u'capabilities':   

{u'exchange_exchange_bindings': True, u'connection.blocked': True,   u'authentication_failure_close': True, u'basic.nack': True, u'per_consumer_qos': True, u'consumer_priorities': True, u'consumer_cancel_notify': True, u'publisher_confirms': True},

 u'cluster_name': u'rabbit@ip-XXX-XX-XX-XXX.ec2.internal', u'platform': u'Erlang/OTP', u'version': u'3.5.7'}, mechanisms: [u'PLAIN', u'AMQPLAIN'], locales: [u'en_US']
</code></pre>

<p>I've tried looking at rabbitmqctl list_exchanges, list_consumers, list_bindings, but I haven't been able to make much sense out of them.</p>

<p>How can I debug this to figure out why RabbitMQ can't send tasks to Celery?</p>