How to Clear DNS Cache on Your Computer (Flush DNS Guide for Developers)

Introduction

clear-DNS-cache

Clearing your DNS cache is a must-know move, whether you’re building a new website, switching environments, or just troubleshooting connectivity issues. DNS cache issues can cause delays, errors, or outdated websites to load. Knowing how to clear DNS cache or flush DNS is crucial for developers. Think of it like hitting refresh on your browser. But for your system’s internal phonebook. In this updated guide, we go all-in on clearing DNS caches across Windows, macOS, Linux, and browsers like Chrome and Firefox. We’ve also added dev-friendly tips like automation, aliases, and scripts so you can streamline your workflow.

Whether you’re building a new website, switching environments, troubleshooting a DNS resolver, or dealing with DNS cache issues, this guide will help. Flushing the DNS cache updates the Domain Name System (DNS) records your computer stores, ensuring faster, more reliable browsing.

What is the DNS Cache?

Your computer stores DNS (Domain Name System) data locally to quickly resolve domain names to IP addresses. While this speeds up web browsing, it can be a nightmare during website updates or DNS propagation. If you’re seeing outdated or incorrect website versions, your DNS cache might be the culprit.

How to Clear DNS Cache on Windows

  1. Press `Windows + R`, type `cmd`, then press Enter.
  2. In the Command Prompt, run:

   “`cmd

   ipconfig /flushdns

   “`

  1. You’ll see a confirmation: `Successfully flushed the DNS Resolver Cache.`
  2. (Optional) Restart your browser or system for full effect.

 

Pro Tip: Create a `.bat` file for easy flushing:

“`bat

@echo off

ipconfig /flushdns

echo DNS Cache Cleared ✅

pause

“`

How to Clear DNS Cache on macOS

Open the Terminal from `Applications > Utilities > Terminal`.

 

For macOS Ventura, Monterey, Big Sur, or later:

“`bash

sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

“`

For older versions:

“`bash

# Yosemite (10.10.4+) and Mavericks

sudo killall -HUP mDNSResponder

 

# Yosemite (10.10.0 – 10.10.3)

sudo discoveryutil mdnsflushcache

 

# Snow Leopard

sudo dscacheutil -flushcache

“`

 

Alias this command in `.zshrc` or `.bash_profile`:

“`bash

alias flushdns=”sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder && echo ‘DNS Cache Cleared ✅'”

“`

🐧 How to Clear DNS Cache on Linux

Linux doesn’t cache DNS by default, but if it does, it’s via a resolver like `systemd-resolved`, `dnsmasq`, `nscd`, or `BIND`. Here’s how to flush them:

       Find your resolver:

“`bash

sudo lsof -i :53 -S

“`

       Based on the resolver:

After identifying your DNS resolver, it’s important to flush DNS to ensure changes take effect.

systemd-resolved:

“`bash

sudo resolvectl flush-caches

“`

dnsmasq:

“`bash

sudo systemctl restart dnsmasq

“`

nscd:

“`bash

sudo nscd -i hosts

“`

BIND:

“`bash

sudo rndc flush

“`

Alias example (for systemd-resolved):

“`bash

alias flushdns=”sudo resolvectl flush-caches && echo ‘DNS Cache Flushed ✅'”

“`

How to Clear DNS Cache in Web Browsers

dns-chrome
3DiconsMediaApps-04

       Google Chrome / Chromium

  1. Open Chrome and enter:

   “`

   chrome://net-internals/#dns

   “`

  1. Click Clear host cache.
  2. Then go to:

   “`

   chrome://net-internals/#sockets

   “`

  1. Click Close idle sockets and Flush socket pools.
  2. Restart the browser.

 

       Mozilla Firefox

  1. Open Firefox and visit:

   “`

   about: networking#dns

   “`

  1. Click Clear DNS Cache.
  2. Restart the browser.

Automate DNS Flushing in Dev Workflows

Add the flush command to a bash alias, or include it in your build/deploy script to ensure you’re never debugging with stale DNS data.

       Bash Alias Example (macOS/Linux):

“`bash

alias flushdns=”sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder && echo ‘DNS Cache Cleared ✅'”

“`

       Hook into a Dev Script:

“`bash

#!/bin/bash

flushdns() {

  sudo dscacheutil -flushcache

  sudo killall -HUP mDNSResponder

  echo “DNS Cache Cleared During Deployment ✅”

}

# Call the function as part of the deployment

flushdns

“`

FAQs:

1. What is DNS cache, and why should I clear it?

The DNS cache stores IP addresses from the Domain Name System (DNS) to speed up browsing. Clearing it removes outdated records and fixes DNS resolver errors.

2. How do I flush DNS cache on Windows?

Open Command Prompt (Win + R, type cmd) and run:

ipconfig /flushdns

You’ll see: Successfully flushed the DNS Resolver Cache. Restart your browser for full effect.

3. How do I flush DNS on a Mac?

Open Terminal and run:

sudo dscacheutil  -flushcache; sudo killall  -HUP mDNSResponder

This works on Ventura, Monterey, Big Sur, and later. Older macOS versions require different commands listed in the guide.

4. Does Linux store DNS cache?

Linux typically doesn’t cache DNS unless you’re using a resolver like [systemd-resolved, dnsmasq, nscd, or BIND]. Check your active service with:

sudo lsof  -i :53  -S
Then, flush the appropriate cache using the matching commands.

5. How do I clear DNS cache in Chrome?

Flushing DNS within Chrome ensures the browser doesn’t hold onto outdated DNS resolver data.

  • Go to:

chrome://net-internals/#dns

  • Click Clear host cache, then go to:

chrome://net-internals/#sockets

Click Close idle sockets and Flush socket pools. Restart the browser.

6. How do I clear DNS cache in Firefox?

Open Firefox and navigate to:

arduino
about: networking#dns

Click Clear DNS Cache and restart the browser to ensure changes take effect.

7. Can I automate DNS flushing?

Yes! You can create aliases or include flush commands in your deployment scripts. This is useful for developers working with staging environments or switching DNS records often.

Example alias for macOS/Linux:

alias flushdns=”sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder”

8. How often should I clear my DNS cache?

There’s no fixed rule, but clear it whenever:

  • You change DNS settings or switch environments
  • You see outdated pages or connection errors
  • You deploy a site with updated domains

9. Is it safe to flush the DNS cache?

Yes! Clearing your DNS cache is completely safe. It won’t affect your files or installed software. It simply resets the list of domain-to-IP lookups stored locally.

10. Does clearing the DNS cache improve internet speed?

No, flushing your DNS cache will not disrupt your internet connection; it simply forces your system to refresh its DNS resolver information.

Conclusion

Clearing or flushing your DNS cache is like changing the oil in your dev environment—easy to skip, but critical for performance and accuracy. Whether you’re working on staging servers, switching DNS records, or deploying a local test site, keeping your DNS cache fresh means fewer headaches and more productive coding sessions.

Bookmark this guide and alias those commands now. Your future self will thank you.

Share this article
Shareable URL
Prev Post

Ultimate Guide to Optimizing Static Websites for Blazing Fast Performance (2025 Edition)

Next Post

How to Create a Subdomain in cPanel (2025 Edition)

Leave a Reply

Your email address will not be published. Required fields are marked *

Read next