About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.
When dig reports NXDOMAIN for a name you believe exists, the server you asked says that name does not exist. RFC 1035's RCODE 3 is "Name Error" and "signifies that the domain name referenced in the query does not exist." RFC 2308 uses NXDOMAIN as "an alternate expression for the "Name Error" RCODE". Where the answer has no CNAME, "the NXDOMAIN response refers to the name in the label of the RR in the question section."
An empty answer with status NOERROR is a different result. RFC 2308 calls that NODATA: the name is valid, and there are no records of the type you asked for. If the server says the name does not exist, the name has to be created, for example by adding an A record. Creating the name will not fix a name that already exists and simply lacks that type.
What the symptom means
NXDOMAIN is a negative answer. The authoritative server "MUST include the SOA record of the zone in the authority section" when it reports NXDOMAIN, so the answer can be cached. The TTL on that SOA "is set from the minimum of the MINIMUM field of the SOA record and the TTL of the SOA itself, and indicates how long a resolver may cache the negative answer." RFC 2308 says that TTL "decrements in a similar manner to a normal cached answer and upon reaching zero (0) indicates the cached negative answer MUST NOT be used again."
A cached NXDOMAIN is stored for the same query name and class. A later query for that name can keep returning NXDOMAIN until the negative TTL reaches zero, even after you add the record.
A CNAME changes which name the error is about. RFC 2308's example has a CNAME in the answer and NXDOMAIN for the target. The name you typed can be real, and the name that does not exist is the target.
dig return code 0 is "DNS response received, including NXDOMAIN status". The exit code does not mean the name exists. The manual says the default is "to print the answer in a verbose form", and +short makes it terse. Read the status in the verbose reply.
Likely causes
| Cause | What you see | How to confirm |
|---|---|---|
| The name was never created, or was removed | NXDOMAIN at the authoritative server | dig @ that server, verbose |
| The label is misspelled | NXDOMAIN for a name close to one that exists | Compare the query with the name in the zone |
| You edited a zone the delegation does not use | The console shows the record, and the authoritative server says NXDOMAIN | dig +trace ends at different servers |
| The name is a CNAME to a missing target | NXDOMAIN, with a CNAME in the answer | The target name, queried the same way |
| A resolver cached the name error | The authoritative server has the record, and your resolver still says NXDOMAIN | Compare dig with no @ to dig @ the authoritative server, and read the negative TTL |
Prove the cause before changing anything
All of these are read-only. The manual's form is dig @server name type. +trace follows referrals from the root and shows the answer from each server. The default type is A.
1. Read the status. Do not use +short.
dig www.example.com A
NXDOMAIN means name error. NOERROR with nothing in the answer is NODATA. SERVFAIL is server failure. Return code 0 does not separate them.
2. Ask the authoritative server.
dig +noall +answer example.com NS
dig @ns1.example.net www.example.com A
dig +noall +answer example.com is the manual's example for a short listing that still includes the type, the TTL and the value. If this server says NXDOMAIN, the name is missing from the zone it serves. If it returns the record and step 1 said NXDOMAIN, you are looking at a cache or a different server.
3. Follow the delegation.
dig +trace www.example.com A
The servers at the end of the trace are the ones the internet asks. A record that exists only on some other server is invisible here.
4. If the answer includes a CNAME, query the target. The name error may be the target, as in RFC 2308's example.
5. If the authoritative server already has the name, read the negative TTL.
dig www.example.com A
RFC 2308's cache time is the lesser of the SOA MINIMUM and the SOA record's own TTL. When a server answers from a cached negative response, RFC 2308 section 6 says it "MUST add the cached SOA record to the authority section of the response with the TTL decremented by the amount of time it was stored in the cache." So the TTL on the SOA record in the authority section of your resolver's NXDOMAIN reply is the time left. Wait until it has reached zero before you treat a resolver's NXDOMAIN as a fresh answer.
Fix
If the name should not exist, the NXDOMAIN answer is correct and the caller is wrong. If it should exist, it has to be added on the servers the trace ends at.
First, save what the authoritative server says now. This command saves its answer for the name, which is NXDOMAIN or empty until you add the record:
dig @ns1.example.net www.example.com A > www-before.txt
Also export the zone, or copy its record list, from your DNS console into a second file named zone-before.txt.
Risk: the next step adds an A record, and an A record at the wrong address sends every lookup of that name to that address. Creating the name also stops the cached name error, once resolvers' negative TTL expires, so a wrong address starts to be used. Adding the name in a zone the delegation does not use leaves the public answer as NXDOMAIN.
Add the record in the zone served by the servers in the trace. Check the address before you save it.
To undo it, delete the one record you added, the record for the name that www-before.txt shows as NXDOMAIN. Leave every other record in zone-before.txt as it is. The name will be NXDOMAIN again after resolvers drop the positive answer they cached.
Example (illustrative): shop.example.com should be 203.0.113.20. dig shop.example.com A is NXDOMAIN. dig @ns1.example.net shop.example.com A is NXDOMAIN, and dig +trace ends at ns1.example.net. The name was never created. The administrator saves the zone, adds the A record, and the direct query returns 203.0.113.20. A resolver that cached the name error still says NXDOMAIN until the negative TTL reaches zero. Deleting the new record is the back-out.
Confirm the fix
dig @the authoritative server returns the record, with status NOERROR, not NXDOMAIN.dig +traceends at those servers and shows the same record.- After the negative TTL from step 5, a query with no
@returns the record as well.
What to watch afterwards
- Removing a name makes the next lookup NXDOMAIN, and that answer is cached.
- A CNAME to a name you delete turns the alias into a name error for the target.
- NODATA is not fixed by creating the name again. The name is already there.
Read next
Related articles you may want next.
- TroubleshootingCertbot "DNS problem: NXDOMAIN looking up A for": the name Let's Encrypt cannot findCertbot says DNS problem: NXDOMAIN looking up A for a name. Check spelling, A and AAAA records, delegation and CNAME targets, then retest with a dry run.Read article
- Troubleshootingdig NOERROR with an empty answer: the name exists, the type does notdig returns NOERROR and an empty answer. The name exists and the queried type does not. Tell NODATA from NXDOMAIN before you add a record.Read article
- TroubleshootingDNSSEC SERVFAIL after changing DNS provider: the stale DS record and the safe order to move a signed zoneDomain gives SERVFAIL after changing DNS provider? Prove a stale DS record with dig +dnssec and +cd, then fix it at the registrar in the safe order.Read article
Risks and limits
- Exit code 0 includes NXDOMAIN. The status line is the result that matters.
- The negative TTL is the lesser of two numbers, not the SOA MINIMUM alone.
- SERVFAIL is a different status from NXDOMAIN.
Sources
- RFC 2308: Negative Caching of DNS Queries (DNS NCACHE) — IETF, March 1998, accessed 22 November 2026
- RFC 1035: Domain Names - Implementation and Specification — IETF, November 1987, accessed 22 November 2026
- BIND 9 manual pages: dig — ISC, BIND 9.20.22 manual, no date shown, accessed 22 November 2026
This article was originally published on .