User Agents

Web browsers and everyday web tech, explained

How to Open DNS Cache: View & Clear Steps

· 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

Opening the DNS cache allows you to view or clear the list of domain names your computer has recently resolved to IP addresses. This can help troubleshoot website loading issues, fix incorrect site redirections, or refresh outdated DNS records. While most operating systems don’t provide a direct interface to “open” the DNS cache like a file, you can access and manage it using built-in command-line tools. This guide shows how to view and clear the DNS cache on Windows, macOS, and Linux systems, with exact commands and safety precautions.

What You'll Need

  • Access to the command line or terminal on your operating system
  • Administrative or root privileges (required for DNS cache commands)
  • Basic familiarity with command-line interfaces
  • Internet connection (to test changes after clearing the cache)

Step-by-Step

  1. Open the command-line interface: On Windows, press Win + R, type cmd, and press Enter. On macOS, open Spotlight (Cmd + Space), type "Terminal," and press Enter. On Linux, open your terminal emulator (Ctrl + Alt + T is common).
  2. Run as administrator (Windows only): Right-click Command Prompt and select "Run as administrator" to ensure you have permission to modify system settings.
  3. Check current DNS cache contents (Windows): Type ipconfig /displaydns and press Enter. This displays all cached DNS entries, including names, record types, and resolved IPs. Scroll through the output to review entries.
  4. View DNS cache (Linux with systemd-resolved): If your Linux distribution uses systemd-resolved, run sudo systemd-resolve --statistics. While this doesn’t show full entries, it displays cache size and hit/miss ratios. To see cached entries, use sudo journalctl | grep "cached" if logging is enabled.
  5. View DNS cache (macOS): macOS does not provide a built-in command to directly view DNS cache contents. However, you can infer activity by monitoring network tools or use third-party apps like "DNS Cache Viewer" from trusted developers. Proceed to clearing if direct viewing isn’t critical.
  6. Clear DNS cache on Windows: After viewing, type ipconfig /flushdns and press Enter. You’ll see a confirmation: "Successfully flushed the DNS Resolver Cache."
  7. Clear DNS cache on macOS (Ventura and later): Enter sudo dscacheutil -flushcache followed by sudo killall -HUP mDNSResponder. These commands reset the cache and restart the DNS responder service.
  8. Clear DNS cache on older macOS (Monterey and earlier): Use sudo killall -HUP mDNSResponder alone. This restarts the DNS service and clears the cache.
  9. Clear DNS cache on Linux (systemd-resolved): Run sudo systemd-resolve --flush-caches. Confirm success with sudo systemd-resolve --statistics to see cache size reset to zero.
  10. Verify cache is cleared: Repeat the display command (e.g., ipconfig /displaydns on Windows). The cache should now be empty or show minimal system entries.
  11. Test website access: Open a browser and visit a site that was previously problematic. The system will perform a fresh DNS lookup, confirming the cache reset was effective.

Common Mistakes

Users often assume the DNS cache is a visible file that can be opened in a text editor, but it’s stored in system memory and only accessible via commands. Another mistake is running commands without administrative rights, which causes permission errors. On macOS, using outdated commands (like lookupd) on newer versions fails because Apple changed the DNS system. Some Linux users forget to check if their system uses systemd-resolved, dnsmasq, or another resolver, leading to incorrect command usage. Finally, skipping the verification step means you won’t know if the flush actually worked.

Tips

Always clear the DNS cache after changing network settings or switching DNS providers. If troubleshooting a specific site, try accessing it before and after flushing to compare load times. On Windows, redirect output to a file using ipconfig /displaydns > dns_cache.txt to review entries later. On macOS, combine DNS flush with renewing DHCP lease (sudo ipconfig set en0 DHCP) for full network refresh. Use consistent command syntax—typographical errors like missing spaces or wrong flags will prevent execution.

Troubleshooting

If ipconfig /flushdns fails on Windows, ensure Command Prompt is running as administrator. On macOS, if killall returns "no process," the mDNSResponder may be named differently—check with ps aux | grep mDNS. On Linux, if systemd-resolve is not found, your system may use dnsmasq or another resolver; check with ps aux | grep dns and consult your distribution’s documentation. If websites still don’t load after clearing the cache, the issue may lie with your DNS server—try switching to a public DNS like Google DNS (8.8.8.8) or Cloudflare (1.1.1.1). Persistent errors may require restarting the network interface or rebooting the system.

Frequently Asked Questions

Can I open DNS cache as a file?

No, the DNS cache is stored in system memory, not as a user-accessible file. You can only view or clear it using command-line tools.

How often does DNS cache update?

Entries expire based on their TTL (Time to Live) value set by the domain. This can range from minutes to days. The cache also clears on system restart or manual flush.

Is clearing DNS cache safe?

Yes, it’s safe and non-destructive. It only removes temporary lookup data. Your system will re-resolve domains as needed.

Why can’t I see DNS cache on macOS?

Apple does not provide a direct command to view cache contents. You can only flush it. Use network monitoring tools for deeper inspection.

Does flushing DNS improve internet speed?

Not directly. It may speed up access to sites with updated DNS records, but it won’t increase overall bandwidth.

Do routers have DNS cache?

Yes, some routers cache DNS. If issues persist, check your router’s admin interface for a DNS flush option.