# Coredns could not resolve hostname

**URL:** <https://discuss.kubernetes.io/t/coredns-could-not-resolve-hostname/30354>\
**Category:** General Discussions\
**Tags:** development, network\
**Created:** [October 31, 2024, 10:26am UTC](https://discuss.kubernetes.io/t/coredns-could-not-resolve-hostname/30354 "2024-10-31T10:26:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thitikorn\_Tuttiam](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/thitikorn_tuttiam/32/16145_2.png) [@Thitikorn\_Tuttiam](https://discuss.kubernetes.io/u/Thitikorn_Tuttiam)\
**Post date:** [October 31, 2024, 10:26am UTC](https://discuss.kubernetes.io/t/coredns-could-not-resolve-hostname/30354/1 "2024-10-31T10:26:45Z")

</div>

Hello,

```
     I have installed master and worker nodes but when started the pods the worker node could not resolve Postgres run on the master node. Do you have any ideas? 

```

error message log worker pod  
psql: error: could not translate host name “postgres” to address: Name or service not known

master and worker it same subnet on VM, I just updated kube to the latest version, but it still happens.

### Cluster information:

Kubernetes version: 1.29.2  
Installation method:  
Host OS: RHEL 8.10  
CNI and version:  
cat /etc/cni/net.d/10-flannel.conflist  
{  
“name”: “cbr0”,  
“cniVersion”: “0.3.1”,  
“plugins”: [  
{  
“type”: “flannel”,  
“delegate”: {  
“hairpinMode”: true,  
“isDefaultGateway”: true  
}  
},  
{  
“type”: “portmap”,  
“capabilities”: {  
“portMappings”: true  
}  
}  
]  
}

CRI and version: crio do not install

docker --version  
Docker version 26.0.0, build 2ae903e

kubectl get nodes  
NAME STATUS ROLES AGE VERSION  
node-401 Ready control-plane 23h v1.29.2  
node-402 Ready 143m v1.29.2

CoreDNS v1.11.1

---

<div class="post-metadata">

**Author:** ![fox-md](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/fox-md/32/10613_2.png) [@fox-md](https://discuss.kubernetes.io/u/fox-md)\
**Post date:** [October 31, 2024, 10:31am UTC](https://discuss.kubernetes.io/t/coredns-could-not-resolve-hostname/30354/2 "2024-10-31T10:31:46Z")

</div>

Hi,  
Can you please explain what do you mean by

> [@Thitikorn\_Tuttiam](#):
>
> `the worker node could not resolve`

Are you trying to resolve postgres entry from the worker node itself?

---

<div class="post-metadata">

**Author:** ![Thitikorn\_Tuttiam](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/thitikorn_tuttiam/32/16145_2.png) [@Thitikorn\_Tuttiam](https://discuss.kubernetes.io/u/Thitikorn_Tuttiam)\
**Post date:** [October 31, 2024, 10:44am UTC](https://discuss.kubernetes.io/t/coredns-could-not-resolve-hostname/30354/3 "2024-10-31T10:44:10Z")

</div>

Sorry, the master node started can resolve the postgres hostname, but the worker node found the error

pods details below.

NAMESPACE NAME READY STATUS RESTARTS AGE IP NODE  
alpha alpha-init-85lrm 0/1 Completed 0 107m 192.168.0.155 dr-node-kube-401  
alpha alpha-postgres-744b858b8b-qjrvm 1/1 Running 0 109m 192.168.0.147 dr-node-kube-401  
alpha alpha-primary-74c44bf774-bwzkj 1/1 Running 0 107m 192.168.0.156 dr-node-kube-401  
alpha alpha-secondary-79f86b8fb6-xsm8w 0/1 Running 0 13m 192.168.1.91 dr-node-kube-402  
kube-flannel kube-flannel-ds-dmv6s 1/1 Running 2 (3h12m ago) 23h 10.89.149.36 dr-node-kube-401  
kube-flannel kube-flannel-ds-tf2hm 1/1 Running 1 (155m ago) 163m 10.89.149.37 dr-node-kube-402  
kube-system coredns-84745cdc89-284pz 1/1 Running 0 15m 192.168.0.158 dr-node-kube-401  
kube-system coredns-84745cdc89-976md 1/1 Running 0 15m 192.168.0.157 dr-node-kube-401  
kube-system etcd-dr-node-kube-401 1/1 Running 2 (3h12m ago) 23h 10.89.149.36 dr-node-kube-401  
kube-system kube-apiserver-dr-node-kube-401 1/1 Running 2 (3h12m ago) 23h 10.89.149.36 dr-node-kube-401  
kube-system kube-controller-manager-dr-node-kube-401 1/1 Running 2 (3h12m ago) 23h 10.89.149.36 dr-node-kube-401  
kube-system kube-proxy-7x9m4 1/1 Running 2 (3h12m ago) 23h 10.89.149.36 dr-node-kube-401  
kube-system kube-proxy-kfvkz 1/1 Running 1 (155m ago) 163m 10.89.149.37 dr-node-kube-402  
kube-system kube-scheduler-dr-node-kube-401 1/1 Running 2 (3h12m ago) 23h 10.89.149.36 dr-node-kube-401

---

<div class="post-metadata">

**Author:** ![zengyliu](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/zengyliu/32/15963_2.png) [@zengyliu](https://discuss.kubernetes.io/u/zengyliu)\
**Post date:** [November 1, 2024, 1:43am UTC](https://discuss.kubernetes.io/t/coredns-could-not-resolve-hostname/30354/4 "2024-11-01T01:43:25Z")

</div>

postgres is one pod`s hostname instead of one service, in the previous kubernetes version, is it ok to resolve the hostname?  
in my understanding, the offical method to access the pods is by the headless service.

---

<div class="post-metadata">

**Author:** ![Thitikorn\_Tuttiam](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/thitikorn_tuttiam/32/16145_2.png) [@Thitikorn\_Tuttiam](https://discuss.kubernetes.io/u/Thitikorn_Tuttiam)\
**Post date:** [November 1, 2024, 11:10am UTC](https://discuss.kubernetes.io/t/coredns-could-not-resolve-hostname/30354/5 "2024-11-01T11:10:25Z")

</div>

I just re-install kube to 1.26.3 1.27.3 1.31.x it still happens

postgres it is okay to resolve hostname if run on host-A or host-B.

If Postgres run host-A, the app on host-B cannot resolve the hostname.

If Postgres run host-B, the app on host-A cannot resolve the hostname.

I suspect a connection between host A and B, but the server is allowed to use all ports. Firewall and iptables are not enabled.
