Celery connect to remote server broker_url
<p>I'm daemonizing celery following the <a href="http://docs.celeryproject.org/en/latest/tutorials/daemonizing.html" rel="nofollow">docs</a>. </p>

<p>My BROKER_URL has been set in the following format:-  <code>'amqp://&lt;user&gt;:&lt;password&gt;@&lt;ip&gt;/&lt;vhost&gt;'</code>.</p>

<p>So, when I start celery manually, <code>celery worker -A app_name</code>, it connects with the remote server. But when I daemonize it, it connects with the localhost amqp. Any reason why?</p>

<p>Here is how I create my celery object:-</p>

<pre><code>app = Celery('c26_search')    
app.config_from_object('django.conf:settings')
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
app.conf.update(
    CELERY_RESULT_BACKEND='djcelery.backends.database:DatabaseBackend'
)
print app.conf.BROKER_URL  # prints remote url
</code></pre>

<p>My settings.py file:-</p>

<pre><code>CELERY_ACCEPT_CONTENT = ['json']
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
BROKER_URL = `'amqp://&lt;user&gt;:&lt;password&gt;@&lt;ip&gt;/&lt;vhost&gt;'`
</code></pre>

<p>Why is it acting so weirdly? Even it prints the remote IP url, but still tries to connects with the local amqp?</p>

<p>Well, I found the answer to the question:-</p>

<p>Pass broker url is <code>CELERY_OPTS</code> as <code>CELERYD_OPTS="-n worker2.%h --broker=amqp://&lt;user&gt;:&lt;password&gt;@&lt;ip&gt;/&lt;vhost&gt;"</code> in celeryd file.</p>

python django celery django-celery djcelery