Has anyone ever said to you, «Hey, you really need to clear your DNS cache»? It’s not an insult. But it’s not a common topic either, so don’t worry if you’ve never done it. We’ll go through the steps required to flush your DNS cache in this tutorial.
It’s a lot easier than it sounds.
You probably know that the Internet’s DNS system matches domain names to server IP addresses. If you perform a ping or traceroute a domain name, you get the IP address of the server the website lives on.
But did you know that the DNS lookup doesn’t take place every time you go to a website? First, your computer or device searches its own local cache to see if you’ve been to the site before. If so, there’s no need to ask the DNS system which IP address belongs to the domain you’re going to visit.
But what happens when your favorite site moves to a new server or IP address? You could be stuck viewing an old version of the website. Or not seeing the site at all, just an error. The same thing can happen when you make certain updates to your own site, like adding a security certificate.
So, how do you force your computer to ask the DNS system where the site is rather than relying on local cache information? Clear your DNS cache.
Let’s take a look at how that’s done.
How to Clear DNS Cache on a Windows Computer
To flush DNS on a Windows 10 computer, open a command prompt. You do that by clicking the Windows Start icon and typing «cmd.» Click either «Open» or «Run as administrator.» You don’t need administrator privileges to clear the DNS cache. Either option will work.
Type «ipconfig /flushdns» and hit your Enter key.
You’ll see the message, «Successfully flushed the DNS Resolver Cache.»
Your next query for a website will consult the DNS system for the most recent record since there are no records in your local cache.
Note that we’re using the terms «clear» and «flush» interchangeably, and while these instructions are specifically for Windows 10, the process is the same for all recent versions of Windows.
How to Clear DNS Cache on a Mac Computer
It’s a little more complicated to flush the DNS cache on a Mac. Open the Terminal program (go to «Applications» then «Utilities» or hit the Command + Space keys to launch Spotlight, then search for «terminal.app»).
The command we’re going to use starts with «sudo,» so you’ll need to enter the administrator password for the account when you run the command.
The exact command to use depends on the O/S version you’re using. But for most of the recent versions, use:
[ht_message mstyle=»info» title=»» show_icon=»» id=»» class=»» style=»»]sudo killall -HUP mDNSResponder[/ht_message]
When the command is executed, you won’t get any feedback that it’s finished. You can add an audio notice of completion by adding «say» to the command:
[ht_message mstyle=»info» title=»» show_icon=»» id=»» class=»» style=»»]sudo killall -HUP mDNSResponder; say DNS flush complete[/ht_message]
If that doesn’t seem to do the trick for you, try one of these older commands:
- sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
- sudo discoveryutil mdnsflushcache; sudo discoveryutil udnsflushcaches
- sudo dscacheutil -flushcache
- lookupd -flushcache
How to Clear DNS Cache in the Chrome Browser
Google’s Chrome browser keeps a DNS cache that could include sites you’ve never visited(!). That happens because Chrome pre-fetches DNS information for all the links on the pages you view. That’s meant to speed up browsing, but it can also make for a large cache over time.
Let’s get rid of it.
Open up Chrome and enter this in the address bar:
[ht_message mstyle=»info» title=»» show_icon=»» id=»» class=»» style=»»]chrome://net-internals/#dns[/ht_message]
Click the «Clear host cache» button.
Like the Mac DNS flush, the Chrome page doesn’t give you any indication that anything has happened, so I leave the page open in a tab for a while to let it do its thing.
There are other caches in Chrome that can affect how some websites are rendered. Go to:
[ht_message mstyle=»info» title=»» show_icon=»» id=»» class=»» style=»»]chrome://settings/clearBrowserData[/ht_message]
(You can also hit the Ctrl + Shift + Del keys, or click the «Customize and control» icon, select «more tools,» then «Clear browsing data…».)
Deleting some kinds of browser cache can wipe out certain day-to-day conveniences that you enjoy, so I don’t want to recommend clearing too much here. But deleting «Cached images and files» is usually enough to troubleshoot website issues.
If you need to know how to clear the Chrome cache on a Mac, we’ve got you covered.
A Little Bit About DNS
You can clear your DNS cache as often as you’d like. There’s no negative impact. The time it takes to resolve domain names to IP addresses without a local cache is usually just a fraction of a second, so it’s not something most of us would notice.
Without going too far out into the weeds, 13 «root» DNS servers hold the master list, so to speak, of all domain to IP correlations. But if we all had to access only 13 servers to do DNS resolution, the web would probably crawl to a halt pretty quickly.
What happens instead is your ISP mirrors (takes a copy of) one of the root servers and uses it on their network. That copy is updated when there are changes on the root server. So when your computer needs to do a DNS lookup to get to a site, you’re talking to your ISP’s DNS servers.
If your ISP’s DNS servers don’t have an answer for your query, they consult one of the root DNS servers.
It Just Works
Most of us never think about the DNS system that makes the web work, and that’s as it should be. It’s a fundamental part of the infrastructure of the Internet, and it’s supposed to work without us giving it any thought.
But when you need to do some troubleshooting, it’s good to know enough to get yourself a fresh DNS result, and hopefully, that’s what we’ve done here.
Do you think about the DNS system every day?
Sorry, that was kind of a trick question. People who have to think about the DNS system every day aren’t reading this. They’re way more important than we are. Don’t bother them.
How about, have you ever had to flush DNS or cache for troubleshooting purposes? How often do you check the cache in your web browsers?