How to Access DNS Cache on Windows, macOS, and Linux
In this article
Accessing the DNS cache allows you to view or clear stored domain name resolutions, which can help resolve website loading issues, troubleshoot network problems, or ensure you're seeing the latest version of a site after DNS changes. The DNS cache stores recent domain lookups to speed up browsing, but outdated entries can cause connectivity errors. This guide explains how to access and manage the DNS cache on Windows, macOS, and Linux systems using built-in command-line tools. You don't need special software—just administrative or terminal access to your machine.
What You'll Need
- Administrative or root access to your computer
- Command Prompt (Windows), Terminal (macOS), or a Linux shell
- Basic familiarity with command-line interfaces
Step-by-Step
- Open the command-line interface: On Windows, press Win + R, type
cmd, and press Enter. On macOS, open Terminal from Applications > Utilities. On Linux, open your preferred terminal emulator (e.g., GNOME Terminal or Konsole). - View the DNS cache on Windows: In Command Prompt, type
ipconfig /displaydnsand press Enter. This displays all cached DNS entries, including domain names, record types, and their corresponding IP addresses. The output can be lengthy; useipconfig /displaydns | findstr "example.com"to filter for a specific domain. - Clear the DNS cache on Windows: Still in Command Prompt, run
ipconfig /flushdns. You’ll see a confirmation: "Successfully flushed the DNS Resolver Cache." This removes all entries and forces your system to query DNS servers again for future requests. - View the DNS cache on macOS (macOS Monterey and earlier): In Terminal, run
sudo dscacheutil -cachedump -entries Host. Enter your password when prompted. This lists cached host entries. For more detail, add| grep -i "name"to extract just domain names. - Clear the DNS cache on macOS (Monterey and earlier): Use the command
sudo dscacheutil -flushcache, followed bysudo killall -HUP mDNSResponderto fully reset the service. Both commands require admin privileges. - Access DNS cache on macOS Ventura and later: Apple changed the caching system. Use
sudo dscacheutil -flushcacheandsudo killall -HUP mDNSResponder—the same commands, but now they apply to the updated resolver. There is no direct command to view the cache; clearing is the primary option. - Check DNS cache on Linux (systemd-resolved systems): Most modern Linux distributions use
systemd-resolved. Runsudo systemd-resolve --statisticsto view cache statistics, including current cache size and transaction metrics. To see cached entries, usesudo systemd-resolve --flush-cachesto clear, orsudo systemd-resolve --statusto check server settings and domains. - Clear DNS cache on Linux with systemd-resolved: Execute
sudo systemd-resolve --flush-caches. You’ll receive no output on success, but the cache is cleared. Confirm by rechecking statistics. - Handle Linux systems using dnsmasq or nscd: If your system uses
dnsmasq, restart it withsudo systemctl restart dnsmasq. Fornscd, usesudo systemctl restart nscdorsudo nscd -i hoststo invalidate the host cache. - Verify changes: After clearing the cache, visit a site that was previously problematic or use
nslookup example.comordig example.comto force a fresh DNS lookup and confirm updated resolution.
Common Mistakes
- Forgetting to run commands with
sudoor as Administrator, leading to permission errors. - Using outdated commands for newer macOS versions—Ventura and later don’t support detailed cache viewing.
- Assuming all Linux systems use the same DNS service—always verify whether
systemd-resolved,dnsmasq, ornscdis active usingps aux | grep -E "(dnsmasq|nscd|systemd-resolve)". - Not restarting network services after cache clearance on some Linux setups, which may delay updates.
- Expecting immediate global DNS changes—flushing your local cache doesn’t affect DNS propagation worldwide.
Tips
- Use
ipconfig /displaydnsbefore and after flushing on Windows to compare entries and confirm removal. - On macOS, combine
ping example.combefore and after flushing to observe TTL and response changes. - On Linux, check which resolver is active with
ls /etc/resolv.conforresolvectl statusto ensure you’re using the correct commands. - Script repetitive tasks: Create a shell script or batch file to flush DNS across reboots or deployments.
- Use
dig +short example.comto get quick DNS lookups without extra detail.
Troubleshooting
If commands fail, first verify you’re using the correct syntax for your OS version. On Windows, ensure Command Prompt is run as Administrator. On macOS, if dscacheutil returns nothing, your system may be using a different caching mechanism—check for third-party tools like dnsmasq. On Linux, if systemd-resolve is not found, try resolvectl (newer syntax) or check if dnsmasq is installed. If network issues persist after flushing, the problem may lie with your ISP’s DNS, router settings, or the website’s DNS configuration. Try switching to a public DNS like Google (8.8.8.8) or Cloudflare (1.1.1.1) to isolate the issue. Also, ensure your system time is correct—incorrect time can break DNSSEC validation and cause resolution failures. If you still can’t resolve domains, restart your router or check firewall settings that might block DNS traffic on port 53.
Frequently Asked Questions
Why can’t I see DNS cache entries on macOS Ventura?
Apple removed direct cache viewing in macOS Ventura. You can only flush the cache using sudo dscacheutil -flushcache and sudo killall -HUP mDNSResponder.
Does flushing DNS improve internet speed?
Not directly. It may resolve specific loading issues caused by stale entries, but it won’t increase overall speed.
How often does the DNS cache update itself?
Entries expire based on their TTL (Time to Live), typically ranging from minutes to hours, depending on the domain’s configuration.
Is it safe to flush the DNS cache?
Yes. It’s a safe, non-destructive process that only clears temporary lookup data.
Can I recover a flushed DNS entry?
No, but it will be re-cached automatically the next time you access the domain, provided it resolves correctly.
Do routers have DNS caches too?
Yes, many home routers cache DNS. You may need to reboot the router or access its admin panel to clear it, depending on the model.