Skip to content

How to Fix CoreDNS Kubernetes DNS Resolution Error

DodaTech Updated 2026-06-24 2 min read

In this tutorial, you'll learn about How to Fix CoreDNS Kubernetes DNS Resolution Error. We cover key concepts, practical examples, and best practices.

CoreDNS pods are in CrashLoopBackOff or pods cannot resolve Kubernetes service names — CoreDNS configuration is missing the Kubernetes plugin or it cannot reach the Kubernetes API server.

The Problem

$ kubectl run test --image=busybox -- nslookup kubernetes.default.svc.cluster.local
Server:    10.96.0.10
Address 1: 10.96.0.10 kube-dns.kube-system.svc.cluster.local
nslookup: can't resolve 'kubernetes.default.svc.cluster.local'

Step-by-Step Fix

Step 1: Check CoreDNS pod status

kubectl get pods -n kube-system -l k8s-app=kube-dns

Step 2: View CoreDNS logs

kubectl logs -n kube-system -l k8s-app=kube-dns

Step 3: Fix CoreDNS ConfigMap

apiVersion: v1
kind: ConfigMap
metadata:
  name: coredns
  namespace: kube-system
data:
  Corefile: |
    .:53 {
        errors
        health {
            lameduck 5s
        }
        ready
        kubernetes cluster.local in-addr.arpa ip6.arpa {
            pods insecure
            fallthrough in-addr.arpa ip6.arpa
            ttl 30
        }
        prometheus :9153
        forward . /etc/resolv.conf
        cache 30
        loop
        reload
        loadbalance
    }

Step 4: Check CoreDNS service

kubectl get svc -n kube-system kube-dns
# Expected CLUSTER-IP: 10.96.0.10

Step 5: Test DNS resolution

kubectl run dns-test --image=busybox --rm -it --restart=Never -- \
  nslookup kubernetes.default

Step 6: Scale up CoreDNS

kubectl scale deployment -n kube-system coredns --replicas=3

Prevention Tips

  • Run at least 2 CoreDNS replicas for high availability
  • Monitor CoreDNS metrics via Prometheus
  • Set resource limits on CoreDNS pods
  • Use pod anti-affinity to spread CoreDNS across nodes

Common Mistakes with kubernetes error

  1. Non-exhaustive pattern matches that compile with warnings then crash at runtime
  2. Misunderstanding that String is [Char] with poor performance for large text operations
  3. Using foldl instead of foldl' causing stack overflow on large lists

These mistakes appear frequently in real-world COREDNS code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

### Why are CoreDNS pods in CrashLoopBackOff?

CoreDNS cannot bind to port 53 or cannot reach the Kubernetes API server. Check if another DNS service is using port 53 on the host. Also check CoreDNS logs for API server connection errors and verify the cluster networking is healthy.

How do I check if CoreDNS is serving DNS correctly?

Run kubectl run dns-test --image=busybox --rm -it --restart=Never -- nslookup kubernetes.default. If resolution fails, check the CoreDNS ConfigMap and logs. Also test with dig @10.96.0.10 kubernetes.default.svc.cluster.local from a cluster node.

What does the kubernetes plugin in CoreDNS do?

The kubernetes plugin enables DNS-based service discovery for Kubernetes services and pods. It translates service names like my-svc.my-namespace.svc.cluster.local to ClusterIP addresses. Without this plugin, Kubernetes service names do not resolve.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro