Learning center

DNS lookup failed: NXDOMAIN, SERVFAIL, NODATA or no answer?

A failed DNS lookup has four shapes, and each one points at a different layer. NXDOMAIN and NODATA are answers: a server says the name, or the record type, does not exist. SERVFAIL means the resolver you asked could not produce an answer, and no reply at all means the query or the response never arrived. Ask the configured resolver and the zone's authoritative server the same question, and compare.

Four outcomes that the application reports as one#

Every DNS response carries a 4-bit response code (RCODE). RFC 1035 defines the ones you meet in incidents: 0 is no error, 2 is server failure ("unable to process this query due to a problem with the name server"), 3 is name error, meaningful only from an authoritative server, and 5 is refused for policy reasons. dig shows the code as NOERROR, SERVFAIL, NXDOMAIN and REFUSED in the status field of its header line. RFC 1035 header and RCODE

NODATA has no RCODE of its own. RFC 2308 defines it as a response with RCODE NOERROR and no relevant records in the answer section, usually with the zone's SOA in the authority section: the name exists, but not with the type you asked for. A name with an A record and no AAAA record returns NODATA for AAAA. RFC 2308 NODATA

The fourth outcome is silence. The client's resolver library retries and then gives up, and the application sees a timeout or a temporary failure. Nothing in DNS said the name was missing.

OutcomeSaysFirst suspect
NXDOMAINThe name does not existThe record, the name, or a zone that shadows it
NODATAThe name exists, not this typeThe record type (A vs AAAA vs CNAME target)
SERVFAILThis resolver could not answerIts upstream, the authority, or DNSSEC
No replyNothing came backThe path to the resolver, or the resolver itself

Why they look alike in the logs#

Applications rarely log the RCODE. They call the system resolver through getaddrinfo or a language runtime, and those flatten the four outcomes into a few error codes. Node.js, for example, sets ENOTFOUND "not only when the host name does not exist but also when the lookup fails in other ways", and its dns.lookup() goes through the operating system facility rather than speaking DNS itself. The error string tells you that resolution failed, not which server said what. Node.js dns.lookup · Reading getaddrinfo errors

The same name can also fail differently from two places. Your laptop, a bastion host and the production container may use different resolvers, search lists and private zones, so a lookup that works from your terminal says little about the service's path.

Ask the configured resolver, then the authority#

Run these from the failing host or container if you can; otherwise from a host in the same network that uses the same resolver. Start with the resolver configuration, then ask that resolver directly, then ask an authoritative server for the zone with recursion turned off. +norecurse clears the recursion-desired bit, and the aa flag in the reply marks an authoritative answer. dig manual · resolv.conf(5)

cat /etc/resolv.conf

# The resolver the service uses, with a short timeout and one try
dig @RESOLVER_IP NAME A +tries=1 +timeout=2

# Find the zone's authoritative servers, then ask one of them directly
dig @RESOLVER_IP ZONE NS +short
dig @AUTHORITATIVE_NS NAME A +norecurse
dig @AUTHORITATIVE_NS NAME AAAA +norecurse

Write down three things from each reply: the status, whether the aa flag is set, and the answer section. If the resolver gives NXDOMAIN or NODATA, read the SOA in the authority section: it names the zone that produced the negative answer, which may be a different zone than you expected.

If you cannot tell which server is authoritative, dig NAME +trace follows the delegation from the root and shows each referral. It sends iterative queries from your host to the root and authority servers directly, so it fails on hosts that may only talk to an internal resolver.

Read the pair#

Configured resolverAuthoritative serverPoints to
NXDOMAINNXDOMAINThe record is missing, or the client asked for a different name
NXDOMAINAnswerThe resolver sees another zone, or still holds a cached negative answer
SERVFAILAnswerThe resolver cannot reach the authority, or DNSSEC validation failed
SERVFAILNo replyThe authoritative servers are unreachable or broken
No replyAnswerThe path to the resolver, or the resolver itself
AnswerDifferent answerSplit-horizon zones or a stale cache

Each row hands off. A resolver that still returns NXDOMAIN after the record was created usually holds a cached negative answer. A resolver that sees a private zone the authority does not will answer differently by design. SERVFAIL with a healthy authority is often a DNSSEC failure, which dig +cd separates. Silence from the resolver while the authority answers points at the network path or a resolver limit. Negative caching after a new record · Split-horizon answers · DNSSEC SERVFAIL

The client can also turn a short name into several queries through its search list, and only the last of them gets logged. If the application asked for orders and the resolver log shows orders.example.internal, that is the name to test.

A worked example: one error, two causes#

This example is illustrative. The checkout service logs failed lookups of payments-api.example.com from 09:40 UTC, and every call to the payments provider fails.

In the first incident:

QueryStatusFlagsAnswer
Configured resolver 10.0.0.2, ANXDOMAINno aanone; SOA of example.com
Authoritative ns1.example.com, ANXDOMAINaanone

Both agree, and the authority speaks for the zone. A record deploy at 09:38 renamed the record to payments.example.com. Nothing is wrong with resolution; the name is gone. Restore the record or point the client at the new name.

In the second incident:

QueryStatusFlagsAnswer
Configured resolver 10.0.0.2, ASERVFAILno aanone
Authoritative ns1.example.com, ANOERRORaa203.0.113.40
Configured resolver, A, +cdNOERRORno aa203.0.113.40

The record exists and the authority serves it. The resolver refuses to hand it over unless validation is disabled, so the zone's DNSSEC chain is broken. Changing the record would not help; the signatures or the DS record at the parent need attention.

Limits#

dig talks DNS directly to one server. It ignores /etc/hosts, the name service switch and any cache inside the application or runtime, so a clean dig result does not clear the application's own lookup path. Use getent hosts NAME on the same host to see what the system resolver returns. getent(1)

A single query is a sample. Intermittent SERVFAIL or timeouts need repeated queries over the failure window, ideally against each resolver address in resolv.conf, since the library tries them in order and only moves to the next after a timeout.

Resolvers that support Extended DNS Errors (RFC 8914) attach a code that explains a SERVFAIL, such as 6 (DNSSEC Bogus) or 22 (No Reachable Authority). Not every resolver sends them, and their absence proves nothing. RFC 8914

For the wider method of deciding whether a dependency or your own release failed, see runtime dependency failures.

Questions#

Does SERVFAIL mean the record does not exist?

No. SERVFAIL says the resolver you asked could not process the query. The record may exist and be served correctly by the authoritative servers. Only NXDOMAIN from an authoritative server says the name does not exist.

Why does dig return an answer while the application still fails?

dig asks one server for one name. The application may expand the name with search domains, read /etc/hosts, use a different resolver from its container's resolv.conf, or reuse a cached result. Run getent hosts NAME inside the same container and compare.

What does REFUSED mean?

The server declined the query for policy reasons, for example because it does not offer recursion to your address. It usually means the client is asking the wrong server, not that the name is missing.

One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. Eligibility and fair-use terms.

Start free with GitHub

Related reading