Skip to content
DevOps & Tools⏱️ 12 min read·

How to Configure DNS Records (A, CNAME, MX, TXT) and Fix Common DNS Errors

Master domain name system (DNS) records. Learn what A, CNAME, MX, and TXT records do, how TTL works, and how to fix ERR_NAME_NOT_RESOLVED, DNS loops, and propagation delays.

MN
Manoj NeupaneSoftware Developer & Programming Instructor
#DNS#Networking#DevOps#Cloudflare#Troubleshooting
🎯 Who This Tutorial Is For

Beginner developers struggling to connect domains to web hosts, VPS instances, or email services.

📋 Prerequisites
  • ✓Access to a domain registrar or Cloudflare DNS management dashboard
  • ✓Terminal access to run dig or nslookup

🚀 What You Will Learn & Build

  • ▸The distinct roles of A, AAAA, CNAME, MX, and TXT records
  • ▸How Time to Live (TTL) influences DNS propagation
  • ▸Diagnosing DNS issues with terminal tools (dig, nslookup, ping)
  • ▸Resolving ERR_NAME_NOT_RESOLVED and circular CNAME loops
1

1. Core DNS Record Types Explained in Simple Terms

DNS is the internet's phonebook, translating human-friendly names (`manoj-neupane.com.np`) into computer IP addresses (`76.76.21.21`). Key Record Types: - **A Record (Address):** Maps a hostname directly to an IPv4 address (e.g., `@` → `159.89.12.34`). - **AAAA Record:** Maps a hostname to an IPv6 address. - **CNAME (Canonical Name):** Maps one domain alias to another domain (e.g., `www.yoursite.com` → `cname.vercel-dns.com`). Note: CNAME cannot legally coexist on root apex (`@`) in standard DNS. - **MX Record (Mail Exchange):** Dictates which mail server handles incoming emails for your domain. - **TXT Record (Text):** Stores arbitrary text, used for domain ownership verification, Google Search Console, and email security (SPF, DKIM, DMARC).
2

2. Diagnosing DNS Using Command Line Tools

Don't guess whether your DNS has propagated. Use terminal commands to query authoritative servers directly:
Terminal
# Check A record of your domain
dig yourdomain.com A +short

# Query specific public DNS (e.g. Google 8.8.8.8 or Cloudflare 1.1.1.1) to bypass local ISP cache
dig @1.1.1.1 yourdomain.com A

# Check MX records
dig yourdomain.com MX +short

# Windows equivalent using nslookup
nslookup -type=A yourdomain.com 1.1.1.1
3

3. Fixing Common DNS Errors

### 1. ERR_NAME_NOT_RESOLVED - **Cause:** No active A or CNAME record exists for the requested subdomain. - **Fix:** Add an A record pointing to your server's IP address or CNAME pointing to your host. ### 2. DNS_PROBE_FINISHED_NXDOMAIN - **Cause:** Domain has expired or nameservers are unassigned/misconfigured. - **Fix:** Verify active status in WHOIS and check that nameservers are assigned properly. ### 3. CNAME Flattening on Apex Domain - **Problem:** Many registrars reject a CNAME on `@` (root). - **Fix:** Use Cloudflare or modern DNS providers that support "CNAME Flattening" (ALIAS record).

✨ Expected Output & Verification

Running 'dig yourdomain.com +short' returns your active server IP address with zero NXDOMAIN errors.

🧪 How to Test the Implementation

  1. 1Test global propagation using whatsmydns.net
  2. 2Clear local DNS cache: 'sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder' on macOS or 'ipconfig /flushdns' on Windows

⚠️ Common Errors & How to Fix Them

❌Multiple conflicting A records

Root Cause: Old hosting provider IP was not deleted when adding new IP.

Fix: Delete the old A record so traffic routes 100% to your new server.

🛡️ Security Considerations & Best Practices

  • !Never share administrative login credentials to your DNS provider.

❓ Frequently Asked Questions (FAQ)

Most modern DNS changes propagate in 2 to 15 minutes, but local Nepali ISPs with aggressive caching may take up to 24 hours.

📌 Summary of Key Takeaways

  • ✓A records point to IP addresses; CNAME points to domain names.
  • ✓Use 'dig' or 'nslookup' with public resolvers (1.1.1.1) to bypass ISP caching.

Official References & Further Reading