A Practical Guide of key information needed to know about DNS to host web apps
Ever deployed a web app only to find yourself staring at a blank screen instead of your beautiful creation? You're not alone. I recently spent many frustrating hours debugging why a newly deployed application wasn't working, only to discover it was a simple DNS configuration issue. DNS problems are the silent killers - they seem simple until they're not, and suddenly you're down a rabbit hole of technical jargon.
The worst part? Most DNS tutorials either oversimplify ("just point your domain to this IP!") or overwhelm you with network engineering concepts you don't need. There's rarely a middle ground that gives developers exactly what they need to know - no more, no less.
You'll run into DNS challenges when:
The good news? You don't need to become a network engineer. Just a few practical concepts will solve most issues you'll face.
By the end of this post, you'll have a practical understanding of DNS that actually matters for web development. I'll give you the mental model and debugging tools to solve 90% of the DNS issues you'll encounter when deploying web applications.
We will define what each (poorly named) entity does and why so you can reason about issues,
You'll learn how to methodically trace DNS issues through the entire resolution chain, with Python code snippets you can run to diagnose problems at each step. Here's a quick example of checking if your domain is properly registered:
import whois
domain = "isaacflath.com"
w = whois.whois(domain)
print(f"Registrar: {w.registrar}")
print(f"Creation Date: {w.creation_date}")
print(f"Expiration Date: {w.expiration_date}")
DNS (Domain Name System) is essentially the internet's phone book - it translates human-friendly domain names like "isaacflath.com" into machine-friendly IP addresses like "192.168.1.1" that computers use to find each other.
This translation happens through a hierarchical system of servers, each responsible for different parts of the domain name resolution process. Understanding this hierarchy is key to diagnosing issues when things go wrong.
This diagram illustrates this hierarchy, from root servers at the top to your specific DNS records at the bottom. Each component plays a crucial role, and problems can occur at any level - which is why having a systematic debugging approach is so valuable. We will walk through each step in this blog post.
🙏 I have a huge amount of gratitude to Alexis Gallagher who has taught me a great deal about DNS. I would not have the knowledge required to write this post if not for him.
As you read the blog post, keep referring back to this diagram and understand where you are in it. This diagram is what you really need to know!
Domain Registrar = The Store Where You Buy Your Listing
Domain Registry = The Official Record Keeper
ICANN = The Governing Authority
Imagine buying a plot of land. The domain registrar is like the real estate agent who handles your purchase, while the domain registry is like the county records office that maintains the official database of who owns what property. You deal with the agent (registrar), who then ensures your ownership is recorded with the official record keeper (registry). ICANN would be like the government agency that regulates real estate transactions and maintains standards.
When you register a domain, your registrar collects your information and payment, then notifies the appropriate registry to record that you now "own" that domain name for the duration of your registration period.
You can check domain registration information using the whois
command
%%bash
whois isaacflath.com | grep Registrar:
This will return detailed information about the domain, including registrar, registration dates, and nameserver information. I have filtered it with grep
to only show the Registrar, but try running it yourself to see all the information it provides!
Here's some key information to look at (you will understand more of what the results mean by the end of the blog post :))
%%bash
whois isaacflath.com | grep -E 'Registrar:|Name Server:|Creation Date:|Expiration Date:' | grep -v 'Registrar URL'
Root Servers = The Top of the DNS Hierarchy
TLD Servers = The Next Level Down
IANA = The Root Zone Manager
Imagine walking into a huge library looking for a specific book. You first go to the main directory at the entrance. This directory doesn't tell you exactly where your book is, but it directs you to the right floor or section (like "Fiction, 3rd floor" or "Science, west wing"). Root servers work the same way - they don't know where "isaacflath.com" is, but they know to direct you to the servers that handle all ".com" domains.
When your computer looks up a website, it often starts by asking a root server "Where can I find information about .com domains?" The root server responds with directions to the TLD servers that handle .com domains.
You can check root servers using the dig
command:
%%bash
dig NS . +short
This will return a list of the root nameservers that form the foundation of the global DNS system.
TLD Servers = The Section Managers of the Internet
Registry Operators = The TLD Administrators
If root servers are like the main directory of a library that points you to different sections, TLD servers are like the section-specific information desks. When you arrive at the "Fiction Section" (the .com TLD), the information desk there doesn't know exactly where every book is, but it can tell you which shelf contains the specific author you're looking for. Similarly, the .com TLD servers don't know the IP address for isaacflath.com, but they know which nameservers are responsible for that domain.
You can check TLD servers using the dig
command:
%%bash
dig NS com. +short
This will return a list of the nameservers responsible for the .com top-level domain, which are crucial in the DNS resolution chain for all .com websites.
Authoritative Nameservers = The Final Authority for Your Domain
DNS Zone = Your Domain's Complete Record Collection
If the DNS system is like a library, authoritative nameservers are the specific bookshelves where your book is stored. When someone asks, "Where can I find the book 'isaacflath.com'?", they're first directed to the main entrance (root servers), then to the correct section (TLD servers), and finally to the exact shelf (authoritative nameservers) where your book is located. The authoritative nameservers then provide the exact location (IP address) where the content can be found.
You can check authoritative nameservers and query them directly using dig:
%%bash
# Find nameservers
dig NS isaacflath.com +short
Check A records from one of these nameservers
%%bash
# Query a specific nameserver for A records
dig @pdns1.registrar-servers.com isaacflath.com A +short
A Records = The Direct IP Address Pointer
CNAME Records = Aliases for Your Domain
CNAME Limitations and Considerations
TTL (Time To Live) = Cache Duration
Other DNS Records = The Specific Instructions for Your Domain
If the DNS system is like a delivery service, A records are the exact coordinates where your package (web request) should be delivered. After going through all previous DNS servers, the browser finally gets the exact address (IP address) where your website is hosted.
CNAME records are like mail forwarding. When a request arrives for "www.example.com," the DNS system checks its records and sees instructions to "forward all requests to example.com instead." The browser then follows that domain's address resolution path.
You can check these records using the dig
command:
%%bash
dig A isaacflath.com +short
%%bash
dig CNAME www.isaacflath.com +short
These commands will show you the IP addresses associated with your domain and any domain aliases, which are essential for directing web traffic to the correct destination.
ISP/Recursive DNS Servers = Your Personal DNS Navigator
DNS Resolution Process = The Complete Journey
DNS Caching = Performance vs. Propagation
If the DNS system is like a library, recursive DNS servers are like research assistants who know the library's organization. When you need information, instead of navigating the complex library system yourself, you simply ask your assistant "Where can I find isaacflath.com?" The assistant either immediately tells you from memory (cache) or goes through the process of consulting the main directory (root servers), finding the right section (TLD servers), and locating the specific shelf (authoritative nameservers) to get your answer.
You can check how different recursive DNS servers resolve your domain:
For example, Google DNS resolution:
%%bash
dig @8.8.8.8 isaacflath.com +short
Or Cloudflare DNS resolution:
%%bash
dig @1.1.1.1 isaacflath.com +short
This will show you how major public DNS providers are currently resolving your domain, which is useful for checking if DNS changes have propagated globally.
Local DNS Cache = Your Device's Memory of Previous Lookups
Browser DNS Cache = Browser-Specific DNS Storage
Think of your local DNS cache like a personal address book. When you need to visit a friend, you first check your address book to see if you already know where they live. Only if you don't have their address (or suspect it might have changed) do you ask someone else. Similarly, your device first checks its local cache before asking recursive DNS servers for domain information.
You can check how your local system is currently resolving a domain using Python:
import socket
domain = "isaacflath.com"
try:
ip = socket.gethostbyname(domain)
print(f"Local resolution: {domain} -> {ip}")
except socket.gaierror as e:
print(f"Resolution error: {e}")
For Windows:
%%bash
# View DNS cache
ipconfig /displaydns
# Clear DNS cache
ipconfig /flushdns
For macOS:
%%bash
# Clear DNS cache (macOS 10.15+)
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
For Linux:
%%bash
# Restart the nscd service if installed
sudo systemctl restart nscd
This allows you to clear your local DNS cache when troubleshooting, which is often the first step in resolving DNS-related issues after making changes to your domain configuration.
import requests
domain = "isaacflath.com"
try:
response = requests.get(f"https://{domain}", timeout=5)
print(f"Status code: {response.status_code}")
print(f"Server responded in {response.elapsed.total_seconds():.2f} seconds")
print(f"Server type: {response.headers.get('Server', 'Unknown')}")
except requests.exceptions.RequestException as e:
print(f"Connection error: {e}")
You can also check if specific ports are open:
When facing DNS problems, follow this systematic approach to identify and resolve issues at each level of the DNS hierarchy:
import whois
domain = "yourdomain.com"
w = whois.whois(domain)
print(f"Registrar: {w.registrar}")
print(f"Creation Date: {w.creation_date}")
print(f"Expiration Date: {w.expiration_date}")
✅ Verify your domain is properly registered and not expired
dig NS yourdomain.com +short
✅ Confirm nameservers match what's configured at your registrar
# A Records
dig A yourdomain.com +short
# CNAME Records
dig CNAME www.yourdomain.com +short
✅ Ensure records point to the correct IP addresses or domains
# Check with different public DNS providers
dig @8.8.8.8 yourdomain.com +short # Google DNS
dig @1.1.1.1 yourdomain.com +short # Cloudflare DNS
✅ If results differ, you may need to wait for propagation
import requests
import socket
# Check HTTP response
try:
response = requests.get(f"https://yourdomain.com", timeout=5)
print(f"Status code: {response.status_code}")
except requests.exceptions.RequestException as e:
print(f"Connection error: {e}")
# Check if ports are open
def check_port(domain, port):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(2)
result = sock.connect_ex((domain, port))
sock.close()
return result == 0
print(f"HTTP (port 80) open: {check_port('yourdomain.com', 80)}")
print(f"HTTPS (port 443) open: {check_port('yourdomain.com', 443)}")
✅ Confirm your web server is responding properly
# Windows
ipconfig /flushdns
# macOS
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
# Linux
sudo systemctl restart nscd
Remember that changes can take time to propagate globally (up to 24-48 hours), though most updates are visible within minutes to hours with modern configurations.
DNS might seem like a complex system, but with the mental model and debugging tools we've covered, you now have everything you need to confidently manage your domain configurations and troubleshoot issues when they arise.
dig
, whois
, and basic Python scripts can save you hours of frustrationNow that you understand DNS fundamentals, try mapping out how your favorite blog's DNS works!
Have you encountered particularly tricky DNS issues? Share your experiences in the comments - I'd love to hear how you solved them and what you learned in the process.
And if this guide helped you solve a DNS problem, let me know! There's nothing more satisfying than knowing these practical guides are making someone's development life a little easier.
Happy deploying!
Get notified about new posts on AI, web development, and tech insights.