DNS Resolution Failures and Timeout - How to Fix
Troubleshooting guide for DNS resolution failures and timeout errors. Learn how to diagnose DNS issues, identify root causes, and fix DNS resolution problems.
DNS Resolution Failures and Timeout - How to Fix
DNS resolution failures and timeouts prevent applications from resolving domain names, causing connectivity issues and service failures. This troubleshooting guide helps you diagnose DNS issues, identify root causes, and fix resolution problems.
For comprehensive DNS monitoring, see DNS Performance Monitoring. For monitoring DNS query times, see Monitor DNS Query Response Times.
Symptoms of DNS Resolution Issues
- DNS query timeouts
- "Name or service not known" errors
- Slow DNS resolution
- Intermittent DNS failures
- Applications unable to resolve domains
Step 1: Test DNS Resolution
Check DNS Resolution
# Test DNS resolution
nslookup example.com
# Test with specific DNS server
nslookup example.com 8.8.8.8
# Test DNS resolution with dig
dig example.com
# Test DNS resolution with host
host example.com
Check DNS Query Time
# Measure DNS query time
time nslookup example.com
# Check query time with dig
dig example.com +stats | grep "Query time"
# Test multiple DNS servers
for dns in 8.8.8.8 1.1.1.1 9.9.9.9; do
echo -n "$dns: "
dig @$dns example.com +noall +stats | grep "Query time"
done
Step 2: Check DNS Configuration
Verify DNS Server Configuration
# Check DNS servers in /etc/resolv.conf
cat /etc/resolv.conf
# Check systemd-resolved configuration
systemd-resolve --status
# Check DNS configuration with nmcli
nmcli dev show | grep DNS
# Check DNS cache
systemd-resolve --statistics
Test DNS Server Connectivity
# Test DNS server connectivity
ping -c 3 8.8.8.8
# Test DNS port connectivity
nc -zv 8.8.8.8 53
# Test DNS server response
dig @8.8.8.8 example.com
Step 3: Identify Root Causes
Common Causes of DNS Failures
-
DNS Server Issues:
- DNS server down or unreachable
- DNS server overloaded
- Incorrect DNS server configuration
- DNS server timeout
-
Network Connectivity Issues:
- Network connectivity problems
- Firewall blocking DNS port 53
- Routing issues
- Network timeout
-
Configuration Issues:
- Incorrect DNS server addresses
- DNS cache issues
- DNS resolver configuration errors
- Systemd-resolved conflicts
-
DNS Record Issues:
- DNS records not propagated
- Incorrect DNS records
- DNS zone configuration errors
- TTL issues
Step 4: Diagnose Specific Issues
Check DNS Server Status
# Test primary DNS server
dig @8.8.8.8 example.com
# Test secondary DNS server
dig @1.1.1.1 example.com
# Check DNS server response time
for dns in 8.8.8.8 1.1.1.1; do
echo -n "$dns: "
timeout 5 dig @$dns example.com +noall +stats | grep "Query time" || echo "TIMEOUT"
done
Check Network Connectivity
# Test network connectivity to DNS server
ping -c 3 8.8.8.8
# Test DNS port connectivity
telnet 8.8.8.8 53
# Check firewall rules
sudo iptables -L | grep 53
sudo firewall-cmd --list-all | grep dns
Check DNS Cache
# Flush DNS cache
sudo systemd-resolve --flush-caches
# Check DNS cache statistics
systemd-resolve --statistics
# Clear DNS cache (alternative)
sudo /etc/init.d/nscd restart # if nscd is used
Step 5: Fix DNS Resolution Issues
Fix DNS Server Configuration
-
Update DNS Servers:
# Edit /etc/resolv.conf sudo nano /etc/resolv.conf # Add DNS servers nameserver 8.8.8.8 nameserver 1.1.1.1 -
Update systemd-resolved:
# Edit systemd-resolved configuration sudo nano /etc/systemd/resolved.conf # Set DNS servers DNS=8.8.8.8 1.1.1.1 # Restart systemd-resolved sudo systemctl restart systemd-resolved
Fix Network Connectivity
-
Check Firewall Rules:
# Allow DNS port sudo ufw allow 53/tcp sudo ufw allow 53/udp # Or with firewalld sudo firewall-cmd --add-service=dns --permanent sudo firewall-cmd --reload -
Fix Network Routing:
# Check routing table ip route show # Test network connectivity ping -c 3 8.8.8.8
Fix DNS Cache Issues
-
Flush DNS Cache:
# Flush systemd-resolved cache sudo systemd-resolve --flush-caches # Restart DNS resolver sudo systemctl restart systemd-resolved -
Clear Application DNS Cache:
- Restart applications using DNS
- Clear browser DNS cache
- Restart services with DNS dependencies
Step 6: Prevent Future DNS Issues
Implement Proper Monitoring
Set up automated monitoring with Zuzia.app to track DNS resolution continuously:
-
Add DNS Resolution Monitoring:
dig example.com +noall +stats | grep "Query time" | awk '{print $4}'- Monitor DNS query times
- Alert when resolution fails
-
Monitor DNS Server Availability:
timeout 5 dig @8.8.8.8 example.com && echo "OK" || echo "FAILED"- Track DNS server availability
- Alert when servers are unreachable
Best Practices
-
Use Multiple DNS Servers:
- Configure primary and secondary DNS servers
- Use reliable DNS providers
- Test DNS server performance
- Monitor DNS server availability
-
Monitor DNS Performance:
- Track DNS query times
- Monitor DNS resolution success rate
- Alert on DNS failures
- Optimize DNS configuration
-
Implement DNS Caching:
- Use local DNS cache
- Configure appropriate TTL values
- Monitor cache performance
- Clear cache when needed
-
Test DNS Configuration:
- Verify DNS server connectivity
- Test DNS resolution regularly
- Monitor DNS performance
- Update DNS configuration
FAQ: Common Questions About DNS Issues
How do I prevent DNS resolution failures?
Prevent DNS resolution failures by using multiple DNS servers, monitoring DNS performance, implementing DNS caching, testing DNS configuration regularly, and ensuring network connectivity.
Why do I get DNS timeouts?
DNS timeouts can be caused by DNS server issues, network connectivity problems, firewall blocking DNS port, or DNS server overload. Check DNS server status and network connectivity.
How do I fix DNS cache issues?
Fix DNS cache issues by flushing DNS cache, restarting DNS resolver service, clearing application DNS cache, and ensuring DNS cache configuration is correct.
Can DNS issues impact application performance?
DNS issues can significantly impact application performance, causing slow response times, connection failures, and service unavailability. Monitor DNS performance and resolve issues promptly.
Related guides, recipes, and problems
-
Related guides
-
Related recipes
-
Related problems