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
# Application references a misspelled service name
DB_HOST=datbase.example.com # typo: missing 'a'# Correct the hostname
DB_HOST=database.example.comThe 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>ordig <host>Check CoreDNS in Kubernetes:
kubectl get pods -n kube-system -l k8s-app=kube-dnsVerify 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-systemFix 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