Skip to content

DNS Resolution Failure

Error message

                lookup failed: no such host
              

Quick summary

DNS cannot find the IP address for the given hostname, usually due to DNS misconfiguration or the hostname not existing.

Why this happens

  • The hostname does not exist or is misspelled

  • The DNS server is unreachable or misconfigured

  • The Kubernetes CoreDNS service is not running or is misconfigured

  • The /etc/resolv.conf file has incorrect DNS server entries

Minimal example

✗ Broken code
# Application references a misspelled service name
DB_HOST=datbase.example.com  # typo: missing 'a'
✓ Fixed code
# Correct the hostname
DB_HOST=database.example.com

The hostname has a typo ('datbase' instead of 'database'). DNS cannot resolve it. The fix corrects the spelling.

How to diagnose

  • Test DNS resolution: nslookup <host> or dig <host>

  • Check CoreDNS in Kubernetes: kubectl get pods -n kube-system -l k8s-app=kube-dns

  • Verify the hostname is correct and the service exists

  • Check resolv.conf: cat /etc/resolv.conf

How to fix

  • Correct the hostname in your configuration

  • Restart CoreDNS: kubectl rollout restart deployment/coredns -n kube-system

  • Fix the DNS server configuration in resolv.conf

  • Add a DNS entry for the hostname if it is a custom internal name

How to prevent

  • Use Kubernetes Service names for internal communication (they have built-in DNS)

  • Monitor CoreDNS health and alert on failures

  • Validate hostnames in configuration before deploying

Related Resources

Related Glossary

← Back to language