Skip to main content

DNS Troubleshooting

Updated 8 min readMarkdown
Part of seriesDNS & Domain Fundamentals for Developers
DNS Troubleshooting

Common Issues and Commands

DNS is an important part of how websites and web applications work.

But sometimes, a domain does not resolve correctly, a website points to an old IP address, or a custom domain stops working after a DNS configuration change.

These problems can be difficult to understand without knowing how to troubleshoot DNS.

In this article, we will explore common DNS problems and learn how to investigate them using practical commands and tools.

1. Common DNS Problems

Before troubleshooting DNS, let's understand some common problems developers may face.

Domain Not Found

A domain or subdomain may not have the required DNS Record.

For example, you may have configured example.com but forgotten to add a record for www.example.com.

This can cause DNS resolution errors.

Wrong IP Address

Your domain may resolve successfully, but it can point to the wrong IP address.

This can happen when an A Record contains an outdated or incorrect IP address.

Old DNS Records in Cache

After changing a DNS Record, some DNS Resolvers may still return the previous value.

This happens because they may have the old record stored in their cache until its TTL expires.

Incorrect Nameservers

Your domain may use Nameservers that do not contain the DNS Records you configured.

For example, you may add records in Cloudflare while your domain still points to another DNS Provider.

DNS Server Problems

Sometimes, a DNS Resolver or an authoritative Nameserver may fail to respond correctly.

This can cause DNS queries to time out or return server errors.

2. Understanding Common DNS Errors

When a DNS query fails, the response can help you understand the problem.

Here are some common DNS response codes:

Response Meaning
NXDOMAIN The requested domain name does not exist
SERVFAIL The DNS server failed to complete the query
NOERROR The query completed successfully, but the requested record may not exist in the answer
REFUSED The DNS server refused the query

NXDOMAIN

NXDOMAIN means that the requested domain name does not exist according to the DNS response.

Possible causes include:

  • Incorrect domain spelling.
  • A missing domain or subdomain.
  • An incorrect DNS configuration.
  • A cached negative response.

SERVFAIL

SERVFAIL means that the DNS Resolver could not complete the query successfully.

Possible causes include:

  • Problems with authoritative Nameservers.
  • DNSSEC validation failures.
  • DNS server configuration problems.

NOERROR with No Answer

Sometimes, a domain exists, but the requested record type is not available.

For example, a domain may have an A Record but no AAAA Record.

The DNS response can return NOERROR without an answer for the requested record type.

This situation is sometimes called NODATA.

DNS Timeout

A timeout happens when a DNS query does not receive a response within the expected time.

Possible causes include:

  • An unavailable DNS server.
  • Network connectivity problems.
  • Firewall rules blocking DNS traffic.
  • DNS server configuration problems.

3. Using nslookup to Check DNS Records

nslookup is a command-line tool that helps you query DNS information.

It is available on Windows, macOS, and Linux.

Check a Domain

nslookup example.com

This returns DNS resolution information for the domain using your configured DNS Resolver.

Check an A Record

nslookup -type=A example.com

This checks the IPv4 record.

Check an MX Record

nslookup -type=MX example.com

This checks the mail servers configured for the domain.

Check Nameservers

nslookup -type=NS example.com

This displays the domain's NS Records.

You can also query a specific DNS Resolver:

nslookup example.com 1.1.1.1

This sends the query to Cloudflare's public DNS Resolver.

4. Using dig to Troubleshoot DNS

dig (Domain Information Groper) is a command-line tool used to query DNS servers and inspect DNS responses.

It is commonly available on Linux and macOS. On Windows, you can use it through environments such as WSL or install a DNS utilities package.

Check an A Record

dig example.com A

This returns detailed information about the A Record query.

To display only the returned IP address:

dig example.com A +short

Check an MX Record

dig example.com MX +short

This displays the mail servers configured for the domain.

Check Nameservers

dig example.com NS +short

This displays the authoritative Nameserver records returned for the domain.

Query a Specific DNS Resolver

dig @1.1.1.1 example.com A

This sends the query to Cloudflare's DNS Resolver.

You can compare it with Google's public DNS:

dig @8.8.8.8 example.com A

Comparing different resolvers can help identify whether the issue is related to a specific resolver or the domain's DNS configuration.

Trace the DNS Lookup

dig +trace example.com

This command follows the DNS delegation path, starting from the Root DNS Servers and continuing toward the domain's authoritative Nameservers.

It helps you investigate problems with DNS delegation and Nameserver configuration.

5. How to Troubleshoot DNS Step by Step

Let's use a practical example.

Imagine you deployed a web application and connected it to:

app.example.com

But the domain is not working.

Here is a simple troubleshooting workflow.

Step 1: Check the Domain Name

First, make sure the domain and subdomain are spelled correctly.

Check that you are using the expected hostname.

For example:

  • example.com
  • www.example.com
  • app.example.com

These are different hostnames and may require different DNS Records.

Step 2: Check the DNS Records

Use dig or nslookup to inspect the records.

For example:

dig app.example.com A +short

Check whether the returned IP address matches the value provided by your Hosting Provider.

Also check whether the required CNAME or other record is configured correctly.

Step 3: Check the Nameservers

Make sure the domain uses the Nameservers of the DNS Provider where you added your records.

Run:

dig example.com NS +short

If the domain points to different Nameservers, you may be editing DNS Records in the wrong provider's dashboard.

Step 4: Compare Different DNS Resolvers

Query more than one Resolver:

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

If the results are different, caching or resolver-specific behavior may be involved.

Step 5: Query the Authoritative Nameserver

You can query the authoritative Nameserver directly.

For example:

dig @ns1.example.net app.example.com A

Replace ns1.example.net with the actual authoritative Nameserver for your domain.

This helps you check whether the authoritative server is returning the expected record without relying on a recursive Resolver's cached answer.

Step 6: Check the TTL and DNS Cache

If you recently changed a DNS Record, check its TTL.

Some Resolvers may still have the previous value cached.

Remember that clearing your local DNS cache only affects your device. It does not clear the cache of public or ISP DNS Resolvers.

6. Clearing the Local DNS Cache

Sometimes, your device may keep old DNS information in its local cache.

You can clear it using operating system commands.

Windows

Open Command Prompt and run:

ipconfig /flushdns

This clears the Windows DNS Client Resolver Cache.

macOS

On current macOS versions, you can run:

sudo dscacheutil -flushcache
sudo killall -HUP mDNSResponder

You may need to enter your administrator password.

Linux with systemd-resolved

If your system uses systemd-resolved, run:

sudo resolvectl flush-caches

The exact cache-clearing method depends on the operating system and DNS service you use.

Important: Clearing your local cache does not clear DNS caches on remote Resolvers.

7. Useful DNS Troubleshooting Tools

Besides command-line tools, there are online services that can help developers investigate DNS problems.

DNS Checker

DNS Checker allows you to compare DNS record results from different locations.

It can help you understand whether DNS changes are visible across different resolvers.

Google Admin Toolbox Dig

This tool allows you to query DNS records using a web interface.

It is useful when you want to inspect DNS information without using the terminal.

DNSViz

DNSViz analyzes DNS configuration and DNSSEC-related problems.

It can help identify issues in the DNS delegation and validation chain.

Summary

Let's review the main tools and commands:

Tool / Command Purpose
nslookup Queries DNS information
dig Inspects DNS records and responses
dig +trace Follows the DNS delegation path
ipconfig /flushdns Clears the Windows local DNS cache
resolvectl flush-caches Clears the systemd-resolved cache
DNS Checker Compares DNS results from different locations
DNSViz Analyzes DNS and DNSSEC configuration

DNS troubleshooting is an important skill for developers.

Understanding DNS responses, checking DNS Records, verifying Nameservers, and using command-line tools can help you identify problems when deploying applications or connecting custom domains.

With these fundamentals, you now have a better understanding of how DNS works and how to troubleshoot common DNS issues.

About the author

  • Software Engineer blending deep algorithmic problem solving with scalable Frontend Architecture. Obsessed with high-performance web systems, Core Web Vitals, accessibility, and modern UI engineering.

No comments yet. Be the first to comment.

DNS & Domain Fundamentals for Developers

Part 10 of 10

A practical introduction to DNS and domain fundamentals for developers. Learn how domain names work, how DNS lookups happen, and how DNS records connect your domain to websites, servers, and email services. This series explains the concepts developers commonly face when deploying projects, connecting custom domains, configuring DNS records, and troubleshooting domain-related issues. The goal is to understand what happens behind the scenes without going too deep into networking.

Start from the beginningWhat Is DNS?Have you ever typed a website name in your browser and opened the website in a few seconds? For example: google.com But how does your computer find the correct website? To understand this, we first ne