Skip to content

/codes/dns/dns-rcodes

DNS response codes (RCODE): NOERROR, NXDOMAIN, SERVFAIL, REFUSED

verified onenvironmentlocal · windows 10.0.26200 arm64 · GNU bash 5.3.15 (Git Bash)updated
tool
DNS
versions
RFC 1035, RFC 6895 and the IANA DNS parameters registry
os
any

Every DNS response carries a response code (RCODE) in its header. NOERROR (0) means the query was answered, NXDOMAIN (3) means the name does not exist, SERVFAIL (2) means the server could not get an answer (often a DNSSEC validation failure or an unreachable authoritative server), and REFUSED (5) means the server will not answer this client. dig shows it in the header line as status: NXDOMAIN.

All registered codes

The list as implemented by dnspython, which follows the IANA registry:

bash
uv run -q --no-project --python 3.13 --with 'dnspython==2.*' python - <<'EOF'
import dns.rcode
for code in dns.rcode.Rcode:
    print(f"{int(code):>2}  {code.name}")
EOF

Output

 0  NOERROR
 1  FORMERR
 2  SERVFAIL
 3  NXDOMAIN
 4  NOTIMP
 5  REFUSED
 6  YXDOMAIN
 7  YXRRSET
 8  NXRRSET
 9  NOTAUTH
10  NOTZONE
11  DSOTYPENI
16  BADVERS
17  BADKEY
18  BADTIME
19  BADMODE
20  BADNAME
21  BADALG
22  BADTRUNC
23  BADCOOKIE

Codes 0 to 15 fit in the 4-bit header field. Higher values (16 and up) need the EDNS(0) OPT record, which carries 8 extra bits; they are used by EDNS, TSIG and cookies.

What they mean in practice

CodeNameMeaningWhat to check
0NOERRORQuery answeredIf the answer section is empty, this is NODATA: the name exists but has no record of that type
1FORMERRThe server could not parse the queryOld servers or middleboxes that reject EDNS; try dig +noedns
2SERVFAILThe server failed to produce an answerDNSSEC validation (dig +cd succeeds?), authoritative servers unreachable, broken delegation
3NXDOMAINThe name does not existTypos, missing record, wrong zone, search domain appended
4NOTIMPQuery type or opcode not implementedUnusual opcodes or types
5REFUSEDThe server refuses to answerQuerying an authoritative-only server for another zone, or a resolver that only serves its own network
6YXDOMAINName exists when it should notDynamic updates (RFC 2136) with prerequisites
7YXRRSETRRset exists when it should notDynamic updates
8NXRRSETRRset that should exist does notDynamic updates
9NOTAUTHServer not authoritative for the zone, or TSIG not authorisedDynamic updates, zone transfers
10NOTZONEName not in the zoneDynamic updates
16BADVERS / BADSIGUnsupported EDNS version / bad TSIG signatureEDNS version, TSIG key
17-22BADKEY, BADTIME, BADMODE, BADNAME, BADALG, BADTRUNCTSIG and TKEY errorsShared key, clock skew between servers
23BADCOOKIEBad or missing server cookieDNS cookies (RFC 7873); clients retry with the new cookie

NXDOMAIN vs NODATA

Both mean "no record", but they are different answers. NXDOMAIN says the name has no records of any type. NODATA is NOERROR with an empty answer: the name exists, but not with the requested type (for example an AAAA query for a host that has only an A record). Resolvers cache both negative answers for the time given by the zone's SOA record (RFC 2308).

Sources