DNS in pod ☸️ Kubernetes

DNS not working inside a Kubernetes pod (could not resolve host / nslookup: can't resolve)

Pods can’t resolve service names or external hosts — CoreDNS is down, blocked by NetworkPolicy, or the upstream resolver fails.

Seen on: Kubernetes

Meaning

Pods use CoreDNS (kube-dns service). Problems: CoreDNS pods crashing or overloaded, NetworkPolicies blocking UDP/TCP 53, wrong ndots search behaviour causing slow lookups, or the node’s upstream DNS failing.

Common causes

  • CoreDNS pods not running/crashlooping (often a loop with host resolv.conf)
  • NetworkPolicy blocks egress to kube-dns port 53
  • Upstream DNS unreachable from nodes
  • Using short names across namespaces (svc instead of svc.namespace)

⚡ Quick fix

  1. Test from a debug pod: nslookup kubernetes.default
  2. Check CoreDNS pods and logs
  3. Allow DNS egress in NetworkPolicies

Detailed fix by platform

Kubernetes

  1. bash
    kubectl run dns-test --rm -it --image=busybox:1.36 --restart=Never -- nslookup kubernetes.default
    kubectl -n kube-system logs -l k8s-app=kube-dns --tail=50

How to diagnose

  1. CoreDNS — Pods Running? Logs?
  2. Policy — Egress to port 53 allowed?
  3. Name — Using svc.namespace.svc.cluster.local?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.