User Agents

Web browsers and everyday web tech, explained

How to Access DNS Cache on Windows, macOS, and Linux

· 5 min read · Cookies and Cache

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

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

  1. 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).
  2. View the DNS cache on Windows: In Command Prompt, type ipconfig /displaydns and press Enter. This displays all cached DNS entries, including domain names, record types, and their corresponding IP addresses. The output can be lengthy; use ipconfig /displaydns | findstr "example.com" to filter for a specific domain.
  3. 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.
  4. 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.
  5. Clear the DNS cache on macOS (Monterey and earlier): Use the command sudo dscacheutil -flushcache, followed by sudo killall -HUP mDNSResponder to fully reset the service. Both commands require admin privileges.
  6. Access DNS cache on macOS Ventura and later: Apple changed the caching system. Use sudo dscacheutil -flushcache and sudo 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.
  7. Check DNS cache on Linux (systemd-resolved systems): Most modern Linux distributions use systemd-resolved. Run sudo systemd-resolve --statistics to view cache statistics, including current cache size and transaction metrics. To see cached entries, use sudo systemd-resolve --flush-caches to clear, or sudo systemd-resolve --status to check server settings and domains.
  8. 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.
  9. Handle Linux systems using dnsmasq or nscd: If your system uses dnsmasq, restart it with sudo systemctl restart dnsmasq. For nscd, use sudo systemctl restart nscd or sudo nscd -i hosts to invalidate the host cache.
  10. Verify changes: After clearing the cache, visit a site that was previously problematic or use nslookup example.com or dig example.com to force a fresh DNS lookup and confirm updated resolution.

Common Mistakes

  • Forgetting to run commands with sudo or 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, or nscd is active using ps 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 /displaydns before and after flushing on Windows to compare entries and confirm removal.
  • On macOS, combine ping example.com before and after flushing to observe TTL and response changes.
  • On Linux, check which resolver is active with ls /etc/resolv.conf or resolvectl status to 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.com to 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.