Chapter 5 · Lesson 7 of 10
Fix it

Fix a domain that does not resolve

A domain that does not resolve returns NXDOMAIN, SERVFAIL or an empty answer, and dig +trace shows which step of the lookup broke so you know whose settings to fix.

By the end you will

Tell NXDOMAIN, SERVFAIL and empty answers apart, find the broken hop with dig, and fix the record, delegation or cache.

Time
20 min
Level
Intermediate
Check
4 questions
You need
  • A domain that fails to load or resolve
  • A terminal with dig installed

Where a lookup fails when a domain does not resolve

When a domain does not resolve, the lookup fails at one hop: the registry has no nameservers, or your nameserver has no record. dig +trace shows which hop failed.
  1. Your machine asks the resolver, which may answer from a cache.
  2. The resolver asks the registry which nameservers the domain uses.
  3. If the domain expired or has no nameservers set, the lookup stops here with NXDOMAIN.
  4. The resolver asks your nameserver for the record.
  5. A missing record or a broken zone gives an empty answer or SERVFAIL.
  6. dig +trace shows which hop failed, so you know whose settings to fix.
Static diagram
  1. Youexample.com?Resolver
  2. Resolverwho is authoritative?Registry
  3. RegistryNS listResolver
  4. ResolverA record?Your nameserver
  5. Your nameserverno answerResolver
  6. ResolvererrorYou

You open app.example.com and the browser says the site cannot be found, or dig returns status: NXDOMAIN or status: SERVFAIL. The name is not turning into an IP address. The cause sits in one of a few places: the record, the delegation at your registrar, the authoritative nameservers, the domain’s registration, or a cache on your side. dig can tell you which one in a few commands.

How it works#

DNS is a chain of delegations. The root servers know who runs .com. The .com registry knows which nameservers the registrar listed for example.com. Those nameservers hold the records, such as the A record that gives your server’s address. A resolver walks that chain and caches what it learns. The pieces are described in DNS record types explained.

A failure at each hop looks different. A missing registry entry or an unregistered name gives NXDOMAIN from the top. A broken nameserver or a validation failure gives SERVFAIL. A name that exists but has no record of the type you asked for gives NOERROR with an empty answer. Knowing the three apart saves most of the debugging.

Step 1: Ask a public resolver#

bash
dig app.example.com A

Read the header line status: and the ANSWER SECTION:

  • NOERROR with an answer: DNS is fine from this resolver. If your browser still fails, the problem is local (Step 7).
  • NOERROR with no answer section: the name exists, but there is no A record. Add one.
  • NXDOMAIN: the name does not exist in the zone, or the domain is not delegated.
  • SERVFAIL: the resolver could not get a valid answer.

Compare with a second resolver to rule out a bad one:

bash
dig @1.1.1.1 app.example.com A +short
dig @8.8.8.8 app.example.com A +short

Step 2: Trace the delegation#

bash
dig +trace app.example.com A

This follows the lookup from the root servers to the TLD servers to your domain’s nameservers. Read it from the top. The last block should come from your nameservers and include the A record. If the trace stops after the TLD with no example.com nameserver lines, the delegation is missing. If it reaches your nameservers but they do not answer or answer without data, the zone there is wrong.

Step 3: Check the nameservers the registry knows#

bash
dig NS example.com +short
dig NS example.com @a.gtld-servers.net

The first shows what resolvers see. The second asks a .com registry server directly (use the correct TLD server for your domain, which +trace prints). The nameservers listed must be the ones where you edit records. A common story: you moved DNS to a new provider and created all the records there, but the registrar still lists the old nameservers, so the new zone is never consulted. Change the nameservers at the registrar and wait for the old NS records’ TTL to pass. See point a domain at your server.

Step 4: Check that the nameservers answer#

Ask each nameserver from Step 3 directly:

bash
dig @ns1.example-dns.net app.example.com A +norecurse

Replace the name with one of your nameservers. A proper answer includes the aa flag (authoritative answer) and your record. A timeout, a refusal, or an answer without aa suggests a lame delegation: the nameserver is listed but does not host the zone. Create the zone at that provider, or remove the stale nameserver from the list.

Step 5: Check that the domain has not expired#

bash
whois example.com

Look at the status and expiry lines. An expired domain may stop resolving after a grace period, and the registrar may put placeholder nameservers on it. The output format varies by registry. Renewing at your registrar is the fix, and it can take a while to propagate. Also check for a registrar hold, such as an unverified contact email, which can suspend a domain.

Step 6: Think about DNSSEC carefully#

If dig shows SERVFAIL on resolvers like 1.1.1.1 and 8.8.8.8 but the authoritative servers answer fine, DNSSEC validation may be failing. Test by asking a resolver to skip validation:

bash
dig app.example.com A +cd

If that returns an answer while the normal query fails, validation is the problem. The typical cause is a DS record left at the registrar after you moved DNS providers, so it points at keys the new provider does not publish. Remove the DS record at the registrar, or enable DNSSEC properly at the new provider and publish its DS. Do this with care and one change at a time, because a wrong DS can take the whole domain offline for validating resolvers.

Step 7: Rule out local caches#

If public resolvers answer but your machine does not, flush local caches. On macOS:

bash
sudo dscacheutil -flushcache && sudo killall -HUP mDNSResponder

On a systemd-resolved Linux machine: sudo resolvectl flush-caches. Check /etc/hosts for an old override, and test with dig @1.1.1.1 to bypass your router. A resolver may also cache a negative answer for a while, so a record you just added can take time to show for those who looked up the missing name first. See DNS propagation and TTL.

Check it worked#

bash
dig @1.1.1.1 app.example.com A +short
curl -I https://app.example.com

You should get your server’s IP, for example 203.0.113.10, and an HTTP response. Check from a second network, such as a phone on mobile data, to be sure it is not only your cache.

Prevent it#

  • Turn on auto-renew at the registrar and keep the contact email current.
  • When you change DNS providers, change nameservers first and handle DNSSEC records deliberately.
  • Keep two or more nameservers, and monitor the domain from outside.

Edge cases and gotchas#

  • Typos in the name: www.exmaple.com returns NXDOMAIN, and the fix is in the browser bar.
  • CNAME at the root: A CNAME cannot sit beside other records at the zone apex, and some providers reject or flatten it.
  • Trailing dots in zone files: A name without a final dot gets the zone appended, producing app.example.com.example.com.
  • Split DNS: An internal resolver may answer differently from public ones. Compare both.
  • TTL on the old record: Changing a record shows slowly for those who cached the old one for its full TTL.
  • Search domains: Your OS may append a search suffix, so test with the full name and a trailing dot.

Troubleshooting#

SymptomLikely causeFix
NXDOMAIN for the whole domainDomain expired or not delegatedRenew it, set nameservers at the registrar
NXDOMAIN only for one subdomainRecord missingAdd the record at the zone provider
NOERROR, no answerNo record of that typeAdd an A or AAAA record
SERVFAIL, +cd worksDNSSEC validation failureFix or remove the DS record at the registrar
SERVFAIL, nameserver times outLame or unreachable nameserverFix or remove that nameserver
Works on phone, not laptopLocal cache or router resolverFlush cache, test with dig @1.1.1.1

Quick reference#

bash
dig app.example.com A
dig +trace app.example.com A
dig NS example.com +short
dig @1.1.1.1 app.example.com A +short
dig app.example.com A +cd
whois example.com

Next#

Continue with Fix permission denied on a Docker volume.

Check what you learned4 questions
1dig shows status: NXDOMAIN. What does it say about the name?
2Which command walks the lookup from the root down, so you can see where it breaks?
3dig NS example.com at the registry shows nameservers you no longer use. Where do you change them?
4status: SERVFAIL appears only for resolvers that validate DNSSEC. What is a likely cause?

Frequently asked questions

What does NXDOMAIN mean?

NXDOMAIN means the name does not exist according to the authoritative nameserver. Either the record is missing, the name is misspelled, or the domain itself is not registered or delegated.

What does SERVFAIL mean in dig?

The resolver could not get a valid answer. Common causes are broken nameservers, a lame delegation, or DNSSEC validation failing. It is a server-side failure, not a missing record.

Why does my domain work on my phone but not my laptop?

Your laptop or router probably caches an old or failed answer, or uses a different resolver. Query a public resolver with dig @1.1.1.1 and flush the local cache.

How long does DNS take to update?

It depends on the record's TTL and on caches that already hold the old answer. A new record with no cached negative answer is often visible at once, while a change can take as long as the old TTL.

Sources

View MD Edit
Share
Helpful?
Progress is saved in this browser only.

Keep going: guides and tutorials

View MD Edit
Share
Helpful?
Run this on your own server

Levelrail deploys apps from git with health-checked releases and one-click rollback.

docker pull ghcr.io/glincker/levelrail:latest Install Levelrail From GLINR Studios