Can't resolve a Service name inside the cluster
If a pod can't resolve a Service name, test with nslookup from inside the cluster, then check resolv.conf, CoreDNS pods, logs and endpoints.
What you see
wget: unable to resolve host address 'hostnames'Resolving hostnames (hostnames)... failed: Name or service not known.nslookup: can't resolve 'kubernetes.default'
What it means
Pods find Services by DNS name. The cluster DNS (CoreDNS) answers those names. When a name fails, either the Service does not exist, or the pod cannot reach working cluster DNS.
How to confirm the cause
- 1Does the Service exist?
kubectl get svc hostnames
Example from the official docs
No resources found. Error from server (NotFound): services "hostnames" not found
This is what a missing Service looks like in the docs.
- 2Try the name from a throwaway pod
kubectl run -it --rm --restart=Never busybox --image=registry.k8s.io/busybox:1.27.2 sh
Then run
nslookup hostnames. If that fails, tryhostnames.default, thenhostnames.default.svc.cluster.local. - 3Test the cluster DNS itself
kubectl exec -i -t dnsutils -- nslookup kubernetes.default
Example from the official docs
Server: 10.0.0.10 Address 1: 10.0.0.10 Name: kubernetes.default Address 1: 10.0.0.1
Create the
dnsutilspod first withkubectl apply -f https://k8s.io/examples/admin/dns/dnsutils.yaml. - 4Check the pod's DNS settings
kubectl exec -ti dnsutils -- cat /etc/resolv.conf
Example from the official docs
search default.svc.cluster.local svc.cluster.local cluster.local nameserver 10.0.0.10 options ndots:5
The search line can differ by cloud provider.
- 5Are the CoreDNS pods up?
kubectl get pods --namespace=kube-system -l k8s-app=kube-dns
- 6Read the CoreDNS logs
kubectl logs --namespace=kube-system -l k8s-app=kube-dns
Look for anything suspicious or unexpected.
- 7Does the DNS Service have endpoints?
kubectl get endpointslice -l kubernetes.io/service-name=kube-dns --namespace=kube-system
Causes and fixes
The Service does not exist or is in another namespace
- HOW TO TELL
kubectl get svcreturns NotFound.- FIX
- Create the Service, for example
kubectl expose deployment hostnames --port=80 --target-port=9376, or use the namespace-qualified name.
CoreDNS is not running
- HOW TO TELL
- No pod, or a failed or completed pod, for
k8s-app=kube-dns. - FIX
- The docs say the DNS add-on may not be deployed by default in your environment and may need to be deployed manually.
DNS Service has no endpoints
- HOW TO TELL
- The kube-dns EndpointSlice is empty.
- FIX
- Follow the Service endpoints runbook for the
kube-dnsService inkube-system.
How to stop it coming back
- Include a DNS check in your cluster readiness tests.
- Alert when CoreDNS pods are not Ready.
Keep going
- Runbook: Service has no endpoints or doesn't reach its pods
- Cheat sheet: kubectl
- Cheat sheet: nslookup
- Cheat sheet: dig
- Lesson: the networking topic in Learn
Sources
Kubernetes documentation (kubernetes.io), read 18 Nov 2026. The docs version selector listed v1.33 to v1.37.