<p>You're using two different host names:</p>
<pre><code>$ rdcli -h dbbackupd.default.cluster.local
$ host dbbackupd.default.svc.cluster.local
</code></pre>
<p>The one used with <code>rdcli</code> is missing <code>.svc</code>.</p>

CC BY-SA 4.0
2020-08-12T07:32:51.107Z
Wow, I feel dumb. I have had a long day, and can't believe I missed something that simple. Anyway, I did confirm that this was the only issue. DNS is working fine, and I can connect to Redis. Thanks for the keen eye.
Brian Reading
CC BY-SA 4.0
2020-08-12T20:30:08.580Z
I've been there myself more times than I'm willing to admit. :) Glad that's all it was.
bradym
CC BY-SA 4.0
2020-08-12T06:08:21.977Z
2020-08-12T06:08:21.977Z
bradym
<p>Can anyone shed some light on why this might not work? I can access redis just fine using the pod's IP address,</p>
<pre><code>$ rdcli -h 10.152.183.65
10.152.183.65:6379&gt; 
</code></pre>
<p>but when I try to use the DNS name, I cannot connect.</p>
<pre><code>$ rdcli -h dbbackupd.default.cluster.local
dbbackupd.default.cluster.local:6379&gt; (error) Redis connection to dbbackupd.default.cluster.local:6379 failed - getaddrinfo ENOTFOUND dbbackupd.default.cluster.local dbbackupd.default.cluster.local:6379
</code></pre>
<p>Inside the pod that is trying to contact redis, I get the right-looking output when using the host command, so name resolution looks good:</p>
<pre><code>$ host dbbackupd.default.svc.cluster.local

dbbackupd.default.svc.cluster.local has address 10.152.183.65
</code></pre>
<p>My theory is that because redis is in a multi-container pod, that dns is not routing it to the container properly. Here is my Service's definition in case that sheds light:</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: dbbackupd
  labels:
    app: dbbackupd
spec:
  selector:
    app: dbbackupd
  type: NodePort
  ports:
    - name: redis-mq
      protocol: TCP
      port: 6379
      targetPort: 6379
    - name: sql-comm
      protocol: TCP
      port: 1433
      targetPort: 1433
</code></pre>

<kubernetes><containers><dns><redis>
Can't hit redis using DNS name in multi-container pod on Kubernetes
Brian Reading
# Can't hit redis using DNS name in multi-container pod on Kubernetes

(Asked by: username_0 on 2020-08-12)

Can anyone shed some light on why this might not work? I can access redis just fine using the pod's IP address,
$ rdcli -h 10.152.183.65
10.152.183.65:6379> 

but when I try to use the DNS name, I cannot connect.
$ rdcli -h dbbackupd.default.cluster.local
dbbackupd.default.cluster.local:6379> (error) Redis connection to dbbackupd.default.cluster.local:6379 failed - getaddrinfo ENOTFOUND dbbackupd.default.cluster.local dbbackupd.default.cluster.local:6379

Inside the pod that is trying to contact redis, I get the right-looking output when using the host command, so name resolution looks good:
$ host dbbackupd.default.svc.cluster.local

dbbackupd.default.svc.cluster.local has address 10.152.183.65

My theory is that because redis is in a multi-container pod, that dns is not routing it to the container properly. Here is my Service's definition in case that sheds light:
apiVersion: v1
kind: Service
metadata:
  name: dbbackupd
  labels:
    app: dbbackupd
spec:
  selector:
    app: dbbackupd
  type: NodePort
  ports:
    - name: redis-mq
      protocol: TCP
      port: 6379
      targetPort: 6379
    - name: sql-comm
      protocol: TCP
      port: 1433
      targetPort: 1433

**Tags:** kubernetes, containers, dns, redis


---

## 1 answers

### Answer by username_1 on 2020-08-12. Score: 3 | Accepted answer

You're using two different host names:
$ rdcli -h dbbackupd.default.cluster.local
$ host dbbackupd.default.svc.cluster.local

The one used with rdcli is missing .svc.

> **Comments:**
> **username_0**: Wow, I feel dumb. I have had a long day, and can't believe I missed something that simple. Anyway, I did confirm that this was the only issue. DNS is working fine, and I can connect to Redis. Thanks for the keen eye.  
> **username_1**: I've been there myself more times than I'm willing to admit. :) Glad that's all it was.  

---

