<p>I have a Django application deployed on a K8s cluster. I need to send some emails (some are scheduled, others should be sent asynchronously), and the idea was to delegate those emails to Celery.</p>
<p>So I set up a Redis server (with Sentinel) on the cluster, and deployed an instance for a Celery worker and another for Celery beat.</p>
<p>The k8s object used to deploy the Celery worker is pretty similar to the one used for the Django application. The main difference is the command introduced on the celery worker: <code>['celery', '-A', 'saleor', 'worker', '-l', 'INFO']</code></p>
<p>Scheduled emails are sent with no problem (celery worker and celery beat don't have any problems connecting to the Redis server). However, the asynchronous emails - &quot;delegated&quot; by the Django application - are not sent because it is not possible to connect to the Redis server (<code>ERROR celery.backends.redis Connection to Redis lost: Retry (1/20) in 1.00 second. [PID:7:uWSGIWorker1Core0]</code>)</p>
<p>Error 1:</p>
<pre><code>socket.gaierror: [Errno -5] No address associated with hostname 
</code></pre>
<p>Error 2:</p>
<pre><code>redis.exceptions.ConnectionError: Error -5 connecting to redis:6379. No address associated with hostname. 
</code></pre>
<p>The Redis server, Celery worker, and Celery beat are in a &quot;redis&quot; namespace, while the other things, including the Django app, are in the &quot;development&quot; namespace.</p>
<p>Here are the variables that I define:</p>
<pre><code>- name: CELERY_PASSWORD
  valueFrom:
    secretKeyRef:
      name: redis-password
      key: redis_password
- name: CELERY_BROKER_URL
  value: redis://:$(CELERY_PASSWORD)@redis:6379/1
- name: CELERY_RESULT_BACKEND
  value: redis://:$(CELERY_PASSWORD)@redis:6379/1
</code></pre>
<p>I also tried to define <code>CELERY_BACKEND_URL</code> (with the same value as <code>CELERY_RESULT_BACKEND</code>), but it made no difference.</p>
<p>What could be the cause for not connecting to the Redis server? Am I missing any variables? Could it be because pods are in a different namespace?</p>
<p>Thanks!</p>

Sofia
<p><strong>Solution from @sofia that helped to fix this issue:</strong></p>
<p>You need to use the same namespace for the Redis server and for the Django application. In this particular case, change the namespace &quot;redis&quot; to &quot;development&quot; where the application is deployed.</p>
