keepcalculator

06 Numbers and Powers

How to Flush Your Local DNS Cache

Card No. 06·51234 · Updated · Standard formula, shown below

Flushing your local DNS cache clears the stored records that map domain names to IP addresses on your computer. This is useful when a website doesn’t load correctly, shows an old version, or returns a ‘server not found’ error even though the site is up. You’ll need administrator or root access to your operating system, and you’ll use a command-line tool (Command Prompt, Terminal, or PowerShell).

What You’ll Need

  • Administrator or root privileges on your computer
  • Access to a command-line interface (Command Prompt, Terminal, or PowerShell)
  • For Windows: the ipconfig command
  • For macOS: the dscacheutil and killall commands
  • For Linux: the systemd-resolve or resolvectl command (depending on your distribution)

Step-by-Step

Windows (all recent versions)

  1. Press Windows Key + R to open the Run dialog.
  2. Type cmd and press Ctrl+Shift+Enter to open Command Prompt as administrator. If prompted by User Account Control, click Yes.
  3. In the Command Prompt window, type the following command and press Enter:
  4. ipconfig /flushdns
  5. You should see the message: Successfully flushed the DNS Resolver Cache.
  6. Close the Command Prompt window. The cache is now cleared.

macOS (macOS Ventura and earlier)

  1. Open Finder > Applications > Utilities > Terminal.
  2. Type the following command and press Enter:
  3. sudo dscacheutil -flushcache
  4. Enter your administrator password when prompted (you won’t see characters as you type).
  5. Then type this command and press Enter:
  6. sudo killall -HUP mDNSResponder
  7. You won’t see a success message. If no error appears, the cache has been flushed.

Linux (using systemd-resolved)

  1. Open your terminal (Ctrl+Alt+T on most distributions).
  2. Check if you’re using systemd-resolved by running: systemd-resolve --status (or resolvectl status on newer versions).
  3. If it responds, flush the cache with:
  4. sudo systemd-resolve --flush-caches (or sudo resolvectl flush-caches).
  5. If you use a different DNS resolver (like dnsmasq or nscd), restart that service instead. For example: sudo systemctl restart dnsmasq or sudo systemctl restart nscd.

Common Mistakes

  • Not running as administrator/root: On Windows, if you don’t open Command Prompt as administrator, you’ll get an error like “The requested operation requires elevation.” On macOS/Linux, you’ll get a permission denied error without sudo.
  • Using the wrong command for your OS: For example, running ipconfig on macOS or dscacheutil on Windows will fail.
  • Typing the command incorrectly: A simple typo like ipconfig /flushdns vs. ipconfig /flushdns (missing the slash) will cause an error.
  • Restarting the wrong service on Linux: If you’re not using systemd-resolved, restarting it won’t clear the cache. Identify your DNS resolver first.

Tips

  • After flushing, you can verify the cache is cleared by running ipconfig /displaydns on Windows (it should show no entries) or by checking the resolver statistics with systemd-resolve --statistics on Linux (cache size should be 0).
  • If you’re troubleshooting a specific website, also try clearing your browser cache, as browsers have their own DNS cache.
  • Flushing DNS doesn’t harm your system; it just means your computer will need to re-query DNS servers for the next few lookups, which is normal.
  • For persistent issues, consider changing your DNS server to a public one (like Google’s 8.8.8.8 or Cloudflare’s 1.1.1.1) to bypass your ISP’s DNS problems.

Troubleshooting

You get an error saying “The requested operation requires elevation” (Windows): Close the Command Prompt and reopen it as administrator (right-click > Run as administrator).

You get “Permission denied” on macOS/Linux: Make sure you prefix the command with sudo and enter your password correctly.

The command runs but you still see old DNS results: This can happen if your router or a proxy server also caches DNS. Try restarting your router, or disable any VPN or proxy temporarily.

On Linux, you get “Command not found” for systemd-resolve: Your distribution may use a different resolver. Try resolvectl (newer systemd) or check if you have dnsmasq or nscd installed. If not, you may need to install one or use sudo /etc/init.d/dnsmasq restart.

You’re on macOS and dscacheutil is not found: This is rare; if it happens, your macOS version might be very old. Try sudo killall -HUP mDNSResponder alone, which works on most versions.

Frequently Asked Questions

How often should I flush my DNS cache?

Only when you’re troubleshooting a DNS-related issue. There’s no need to flush it regularly; the cache automatically expires entries based on their TTL (time-to-live).

Will flushing DNS speed up my internet?

No, it may temporarily slow down browsing because your computer has to re-query DNS servers for every domain. It won’t improve your connection speed.

Does flushing DNS clear my browser history?

No, it only clears the DNS cache on your operating system. Your browser’s history, cookies, and its own DNS cache remain untouched.

Why does a website still show the old IP after flushing?

Your router or an intermediate proxy may also have a DNS cache. Also, the website’s DNS records might have a long TTL, so other DNS servers still have the old info. Wait a few hours or try a different DNS server.

Can I flush DNS on my phone?

Yes, on Android and iOS, you can simply toggle Airplane mode on and off, or restart the device. There’s no built-in command-line method without rooting/jailbreaking.

Is it safe to flush DNS?

Yes, it’s completely safe. It’s a standard troubleshooting step and doesn’t delete any personal data or settings.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →