DNS error codes
The short version
- Every DNS answer carries a small code that says how the lookup went.
- NXDOMAIN means the name doesn't exist. SERVFAIL means the server had a problem. REFUSED means it wouldn't answer.
- "The name exists but has no record of that type" is a different case, called NODATA.
digshows the code on itsstatus:line.
Where the code comes from
Every reply from a DNS server has a header. In the header is a 4-bit field called the response code, or RCODE.[1] Think of it as the first word of the reply. It tells you whether the server could help before you read the rest.
A code of 0 means no error. The other codes explain what went wrong. The resolvers chapter shows who is asking whom. A code can come from your resolver or from your domain's own nameserver, so it helps to know which one spoke.
NXDOMAIN: no such name
The standard calls code 3 a "Name Error". It signifies that the domain name referenced in the query does not exist.[1] People say NXDOMAIN, short for "non-existent domain".
Most often it's a typo. Look up wwww.example.com and you get NXDOMAIN. It also happens when you haven't added the record yet, or you added it in the wrong place. Check the spelling first. Then check that the record is in the zone your nameservers really serve. The nameservers chapter explains how to find those.
Resolvers remember this answer for a while. The SOA chapter covers how long.
SERVFAIL: the server had a problem
Code 2 is "Server failure". The name server was unable to process the query due to a problem with the name server.[1]
The word to notice is problem. The name might be fine. The server couldn't finish the job. The code alone doesn't say why. Ask a different resolver, then ask your domain's own nameserver directly. If only one resolver fails, the fault is probably with that resolver. If all of them fail, look at your domain's setup. A domain that uses DNSSEC is worth checking too.
REFUSED: it won't answer you
Code 5 is "Refused". The server refuses to perform the operation for policy reasons.[1]
That means the server is working. It just won't talk to you. A common mistake is asking a server about a domain it doesn't handle. You can't fix that from the domain side. Ask a different server, or fix which server you're asking.
The rarer codes
Two more come from the same list:
- FORMERR (code 1): the server was unable to interpret the query.[1]
- NOTIMP (code 4): the server does not support the requested kind of query.[1]
You will almost never see these with ordinary lookups.
NODATA: not an error code at all
Sometimes the name exists, but you asked for a record type it doesn't have. For example, you ask for the AAAA record of a name that only has an A record.
The reply doesn't use a special code. NODATA is indicated by an answer with the RCODE set to NOERROR and no relevant answers in the answer section.[2] The standard calls it a pseudo code. It says the name is valid, but there are no records of the given type.[2]
So an empty answer with NOERROR is not "broken". It means "that name is real, but not for that type". Compare it with NXDOMAIN, where the name itself isn't there.
Seeing the code with dig
Run a lookup without +short. The dig chapter shows the basics.
$ dig wwww.example.com A
Near the top of the output is the header line. The code is after status:.
A name that exists and has the record shows status: NOERROR with an answer below. A missing name shows status: NXDOMAIN. If you see NOERROR but an empty answer, you've met NODATA.
Next: putting it to use
When a site won't load, read the code before you change anything. NXDOMAIN points to the name or zone. SERVFAIL points to a server. REFUSED points to who you asked. The last chapter shows a full setup to check against.
Sources
- RFC 1035: Domain Names, Implementation and Specification, IETF (accessed 2026-11-01)
- RFC 2308: Negative Caching of DNS Queries (DNS NCACHE), IETF (accessed 2026-11-01)