The DNS resolver your client is talking to is failing to get a valid answer from an upstream DNS server, and it’s giving up.
This usually means there’s a problem somewhere between your client and the authoritative DNS servers for the domain you’re trying to reach, or the authoritative servers themselves are having issues.
1. Network Connectivity to Upstream DNS Servers
- Diagnosis: From the client experiencing the
SERVFAIL, try pinging the upstream DNS server IP address. If you’re using a public DNS server like Google’s8.8.8.8or Cloudflare’s1.1.1.1, this is straightforward. For a local resolver, identify its upstream servers usingresolvectl status(on systemd-based systems) or by checking/etc/resolv.conf.ping 8.8.8.8 - Fix: If ping fails, there’s a network issue. Check firewall rules on the client, any intermediate firewalls, or network routing. Ensure UDP/53 and TCP/53 traffic is allowed to the upstream DNS servers. For example, on an
iptablesfirewall:
This explicitly allows outgoing DNS traffic tosudo iptables -A OUTPUT -p udp --dport 53 -d 8.8.8.8 -j ACCEPT sudo iptables -A OUTPUT -p tcp --dport 53 -d 8.8.8.8 -j ACCEPT8.8.8.8.
2. Upstream DNS Server Unreachable or Down
- Diagnosis: Use
digto query a known-good domain against the specific upstream server that might be failing. If you suspect a particular upstream server (e.g.,192.168.1.1on your local network), query it directly.
If this query times out or returnsdig @192.168.1.1 google.comSERVFAILitself, the upstream server is the problem. - Fix: If your upstream DNS server is a local router or a dedicated DNS server, restart it. If it’s a public DNS server like
8.8.8.8and it’s consistently failing, switch to an alternative public DNS provider (e.g.,1.1.1.1,9.9.9.9) in your client’s network settings or router configuration. For example, on Linux, edit/etc/resolv.conf:
This tells the system to try Cloudflare’s DNS first, then Google’s secondary.nameserver 1.1.1.1 nameserver 8.8.4.4
3. DNSSEC Validation Errors
- Diagnosis: DNSSEC can cause
SERVFAILif the client’s resolver is configured to validate DNSSEC signatures but encounters a broken chain of trust or invalid signatures for the domain being queried. Usedig +dnssecto see the DNSSEC records.
Look fordig +dnssec google.com Astatus: SERVFAILand check the flags forad(authenticated data). If it’s missing or!<ad>, validation might be failing. - Fix: The most common fix is to disable DNSSEC validation on the client or local resolver if you don’t strictly need it and are experiencing persistent
SERVFAILs for specific domains. Onsystemd-resolved, this is done by editing/etc/systemd/resolved.conf:
Then restart[Resolve] DNSSEC=nosystemd-resolved:sudo systemctl restart systemd-resolved. This tells the resolver to stop performing DNSSEC checks.
4. Local Resolver Configuration Issues (e.g., dnsmasq, unbound)
- Diagnosis: If you run your own DNS resolver (like
dnsmasqorunbound), check its logs for errors. Fordnsmasq, logs are often found in/var/log/syslogor/var/log/messages. Forunbound, check its specific log file as configured. Also, check the configuration file for syntax errors or incorrect upstream server settings.sudo grep -i 'error\|fail' /var/log/syslog | grep dnsmasq - Fix: Correct any syntax errors in the configuration file (e.g.,
/etc/dnsmasq.confor/etc/unbound/unbound.conf). Ensure theserver=directives point to valid, reachable upstream DNS servers. After correcting, restart the service:
This reloads the configuration and applies the fixes.sudo systemctl restart dnsmasq
5. Incorrect DNS Records on Authoritative Server
- Diagnosis: The issue might not be with your client or intermediary servers, but with the authoritative DNS servers for the domain itself. Use
digto query the authoritative servers directly for the domain in question. You can find the authoritative servers using adig NSquery for the domain.
If the authoritative server returnsdig google.com NS dig @ns1.google.com google.com ASERVFAILor an incomplete answer, the problem is there. - Fix: This requires access to the DNS management console for the domain. You’ll need to contact the domain administrator to check and correct the DNS records (e.g., A, AAAA, MX, CNAME) for the domain. Ensure all necessary records are present and correctly formatted, and that the glue records for the NS records are also correct.
6. Firewall Blocking Outgoing DNS Queries from the Resolver
- Diagnosis: If your client is configured to use a local DNS resolver (e.g., your router or a server on your network), that resolver itself might be blocked from reaching its upstream DNS servers. Test connectivity from the resolver machine itself.
# On the resolver machine ping 8.8.8.8 dig @8.8.8.8 google.com - Fix: Examine the firewall rules on the DNS resolver machine or network device. Ensure it can make outbound UDP/53 and TCP/53 requests to its configured upstream DNS servers. For example, on a Linux server acting as a resolver:
This opens outbound DNS ports on the firewall.sudo ufw allow out 53/udp sudo ufw allow out 53/tcp
The next error you’ll likely hit after fixing SERVFAIL is NXDOMAIN if the DNS records themselves were malformed or missing, or a timeout if the underlying network issue persists.