<p>I am running Celery in Kubernetes pod. It can't find the server:</p>
<blockquote>
<p>ERROR/MainProcess] consumer: Cannot connect to redis://:**@redis-master:6379/1: Error -3 connecting to redis-master:6379. Lookup timed out..
Trying again in 4.00 seconds... (1/100)</p>
</blockquote>
<p>If I connect to the very same pod via &quot;kubectl exec -it&quot; and run the command, I succeed:</p>
<blockquote>
<p>redis-cli -u redis://:@redis-master:6379/1 keys '*'</p>
<p>(empty list or set)</p>
</blockquote>
<p>How can I troubleshoot this problem?</p>
<hr />
<p><strong>UPDATE 1</strong>:
Problem obviously in DNS:</p>
<p>If I set host to domain name:</p>
<pre><code>export REDIS_HOST=redis-master.dev.svc.cluster.local
celery worker --app src
TIMEOUT
</code></pre>
<p>If I set host to domain name:</p>
<pre><code>export REDIS_HOST=10.0.13.13
celery worker --app src
OK
</code></pre>
<p>Meanwhile:</p>
<pre><code># dig redis-master.dev.svc.cluster.local
; &lt;&lt;&gt;&gt; DiG 9.11.5-P4-5.1+deb10u1-Debian &lt;&lt;&gt;&gt; redis-master.dev.svc.cluster.local
;; global options: +cmd
;; Got answer:
;; WARNING: .local is reserved for Multicast DNS

;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 49071
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;redis-master.dev.svc.cluster.local. IN A

;; ANSWER SECTION:
redis-master.dev.svc.cluster.local. 30 IN A 10.0.13.13

;; SERVER: 10.0.0.10#53(10.0.0.10)
</code></pre>
<p>Thus, the problem is narrowed down to:
Why Celery doesn't use DNS?</p>
<hr />
<p><strong>UPDATE 2</strong>:
Problem in Python library <a href="https://pypi.org/project/dnspython/#history" rel="nofollow noreferrer">dnspython</a>.
Version 2.0.0 - bug in resolving
Version 1.16.0 - works like a charm</p>
<hr />
<p><strong>SOLUTION</strong></p>
<p>pip install dnspython==1.16.0</p>

Michael A.
<p>Answering myself:</p>
<p>This is a dnspython bug.
Solution:</p>
<pre><code>pip install dnspython==1.16.0
</code></pre>
