Local DNS Caching: What It Is and How It Works
In this article
Local DNS caching is the temporary storage of domain name resolution results on your own device (computer, phone, or router) so that repeated requests for the same website load faster and reduce network traffic. When you type a domain like example.com, your device checks its local cache before asking a DNS server, and if the entry is fresh, it uses that IP address directly—no external query needed. This is standard behavior in every modern operating system and router.
Why DNS Caching Exists
Every time you visit a website, your device needs to convert the human-readable domain name (e.g., smartsystemsforhome.com) into an IP address (like 192.0.2.1). That conversion is called a DNS lookup, and it normally requires a request to a DNS resolver, which may be your ISP's server or a public service like Google Public DNS. Without caching, every single request for every resource (images, scripts, stylesheets) would trigger a new lookup, adding latency and loading the DNS infrastructure unnecessarily.
Caching solves this by storing the answer locally for a limited time. The duration is controlled by the Time-to-Live (TTL) value that the DNS server attaches to each record. TTLs are measured in seconds and can range from 30 seconds to 24 hours or more. When the TTL expires, the cached entry is discarded, and the next lookup goes back to the DNS server.
How Local DNS Caching Works
Here is the step-by-step process that happens when you request a website:
- Your browser asks the operating system for the IP address of the domain.
- The OS checks its local DNS cache (a memory-resident table).
- If the entry exists and is not expired, the OS returns the IP address immediately—no network request is made.
- If the entry is missing or expired, the OS sends a DNS query to the configured resolver (usually your router or ISP).
- The resolver may also have its own cache, and if not, it queries authoritative DNS servers.
- Once the answer is received, the OS stores it in its local cache with the TTL from the response.
- The browser connects to the returned IP address and loads the site.
On most systems, the cache also stores negative results (e.g., “domain not found”) for a short time to avoid hammering a failing server. This is called negative caching.
Where Local DNS Caches Live
There are three common places where DNS caching occurs on your local network:
- Operating system cache: Windows, macOS, Linux, Android, and iOS all maintain a DNS cache. On Windows, you can view it with
ipconfig /displaydnsand clear it withipconfig /flushdns. On macOS, usesudo dscacheutil -flushcache(the exact command varies by version). - Router cache: Many home routers run a DNS forwarder that caches responses for all devices on the network. This speeds up lookups for the whole household.
- Browser cache: Some browsers (like Chrome and Firefox) have their own DNS cache, separate from the OS. Chrome's cache can be viewed at
chrome://net-internals/#dnsand cleared by clicking “Clear host cache.”
Note that the exact menu labels and commands can differ slightly by version, device, or region.
Common Problems and How to Fix Them
Stale DNS cache entries are a common source of “website not loading” issues, especially after a site changes its IP address. Typical symptoms include:
- You get an error like “This site can’t be reached” even though the site works on other devices.
- You are redirected to an old server that shows an outdated version of the site.
- You see a “DNS_PROBE_FINISHED_NXDOMAIN” error in Chrome.
If you suspect a stale cache, the safest first step is to clear your local DNS cache. On Windows, open Command Prompt as administrator and run ipconfig /flushdns. On macOS, run sudo dscacheutil -flushcache and then sudo killall -HUP mDNSResponder (the second command may not be needed on newer versions). On a router, you can usually reboot it or find a “Clear DNS Cache” option in the admin interface.
If clearing the cache does not help, try restarting your router, then check if the problem persists. If it does, the issue may be with the DNS server itself—try switching to a public DNS like Google (8.8.8.8) or Cloudflare (1.1.1.1) temporarily to see if that resolves it.
Flushing DNS Cache: When and How
Flushing the DNS cache is a safe troubleshooting step that does not delete any personal data. It simply removes the temporary IP address mappings. You might need to flush when:
- You’ve changed your website’s hosting and want to see the new version immediately.
- You’re getting connection errors that only affect your device.
- You’ve configured a new DNS server and want to discard old entries.
Here are the standard commands for each platform:
- Windows: Open Command Prompt (Admin) and type
ipconfig /flushdns. - macOS: Open Terminal and type
sudo dscacheutil -flushcache; on older versions you may needsudo killall -HUP mDNSResponder. - Linux: The command depends on the DNS resolver. For systemd-resolved, use
sudo systemd-resolve --flush-caches. For older systems, you may need to restart the network service. - Chrome browser: Go to
chrome://net-internals/#dnsand click “Clear host cache.” - Router: Reboot it or look for a “DNS Cache” option in the admin panel.
Local DNS Cache vs. Public DNS Cache
It’s easy to confuse local DNS caching with the caching that happens on public DNS servers like Google Public DNS or OpenDNS. The key difference is where the cache resides:
- Local cache: Stored on your device or router. It only benefits that specific device or network.
- Public DNS cache: Stored on the DNS provider’s servers. It benefits all users who query that server, but you have no direct control over it.
When you flush your local cache, you are only clearing your own device’s memory. The public DNS server may still have a cached copy of the old IP address, which can cause the same problem. If you’ve flushed your local cache and still see stale results, try querying a different public DNS server or wait for the TTL to expire.
Security and Privacy Considerations
Local DNS caching is generally safe and has no direct security risks. However, there are a few things to keep in mind:
- DNS poisoning: If an attacker can modify your local DNS cache, they could redirect you to fake websites. This is rare on modern systems because OS-level caches are protected by permissions, but it’s a reason to keep your system updated.
- Privacy: Your local DNS cache reveals which domains you’ve visited, but only to someone with local access to your device. Using DNS-over-HTTPS (DoH) or DNS-over-TLS (DoT) encrypts queries to your resolver, but does not affect local caching.
- Recording laws: If you are troubleshooting network issues that involve monitoring traffic, be aware that recording or capturing network traffic may be subject to local laws. Always ensure you have permission to monitor devices you do not own.
If you are concerned about DNS privacy, you can configure your device or router to use a DNS service that supports encryption, such as Cloudflare’s 1.1.1.1 or Google Public DNS over HTTPS. These services are free and do not require any special hardware.
Frequently Asked Questions
Does clearing the DNS cache speed up my internet?
No, clearing the DNS cache does not speed up your internet. It actually slows down the first few lookups because your device has to query a DNS server again. The benefit is that it removes stale entries that might be causing errors. If you don’t have a DNS problem, there is no need to flush.
How long does a DNS cache entry last?
It depends on the TTL set by the domain’s DNS records. TTLs can range from 30 seconds to 24 hours or more. Most sites use TTLs between 300 and 3600 seconds (5 minutes to 1 hour). Your device will discard the entry after that time, even if you don’t flush it.
Why does my website still show the old IP after I flushed my cache?
Because the stale entry may still exist in your router’s cache, your ISP’s DNS cache, or a public DNS server. Flushing your local cache only clears your device. Try rebooting your router or using a different DNS server to see if that helps.
Can I disable DNS caching on my computer?
On Windows, you can disable the DNS client service (called “DNS Client”) via Services.msc, but this is not recommended because it breaks name resolution for many applications and can cause system instability. On macOS, there is no official way to disable it. The cache is a fundamental part of the networking stack, so it’s best to leave it enabled.
Does a VPN affect local DNS caching?
Yes. When you connect to a VPN, your DNS queries are typically sent through the VPN tunnel to the VPN provider’s DNS servers. Your local cache still stores the answers, but the entries are specific to the DNS server used. If you disconnect the VPN and try to access the same domain, the cached IP might be unreachable because it was assigned by the VPN’s DNS. Flushing the cache after disconnecting can help.