How to Clear Your DNS Cache on Windows, macOS, Linux, and Chrome
The Complete Guide to Flushing Local DNS Records on Any Operating System
A clear DNS cache is an easy way to solve connectivity issues, as well as prevent some of the most widely-encountered DNS-based cyberattacks. But how can you do that on your endpoints?
In the following lines, you will find an overview of what a DNS cache is, as well as the importance of flushing it, before diving into a step-by-step guide on how to achieve this on various operating systems as well as in your browser.
What is a DNS Cache?
The domain name system (DNS) cache is the computer’s storage area for recent queries to DNS name servers. When a user sends out a full DNS query including A records and/or MX records, these responses are kept in the DNS cache until they expire, either by the operating system or the browser.
These records map domain names to IP addresses so the domain name doesn’t have to be separately looked up each time it is referenced. When a user wishes to visit a website for the first time, the process can take anywhere from dozens of milliseconds to over a minute. However, if the user visits many times, then this process may take only milliseconds because the website record has been cached in the browser’s or system’s DNS Cache and the IP address doesn’t need to be looked up again.
A DNS server is connected to each hub/router. The latency time for a request for a domain name diminishes as it bounces along to each successive router. Determining the caching DNS server with the lowest latency time is key to accessing the name efficiently. Moreover, when one machine offloads an IP route request, the load gets distributed across those data centers. This results in faster ping and lookup times overall.
Why Should I Flush My DNS Cache?
Flushing your local DNS cache every once in a while is a good cyber-hygiene practice that both home and business users should consider. But why is it important? For one, it helps you make sure that the information stored on it is up to date.
Sometimes, the records stored by the cache can become outdated, as it takes them up to 48 hours to propagate across worldwide servers. This can cause some websites to not load properly, but performing a simple clear DNS cache operation can solve the issue in minutes.
In addition to this, executing a flush on your local DNS cache is a simple fix to DNS server connectivity issues. What is more, clearing the records regularly is a straightforward DNS security measure that helps you prevent DNS spoofing attacks.
It’s no secret that hackers can sometimes intercept the queries you make online when trying to reach a particular website. Fortunately, a local DNS cache flush will prevent them from doing so or at least make their job a lot harder because resolvers need to obtain an authoritative answer for the request made in the browser before completing the process.
How to Clear DNS Cache on Windows
Does your machine run on the popular Windows operating system? Below, you will find step-by-step instructions on how to clear the DNS cache on Windows XP, Windows 7, Windows 8, and Windows 10 respectively.
Windows XP and 7
If you want to flush your local DNS cache on a Windows machine, you need to first locate the Command Prompt program. For Windows XP or Windows 7, start by clicking the Start button, then go to All Programs > Accessories > Command Prompt. Once you’re in the command line interface, run the following command:
Once the DNS cache has been cleared, you should receive a confirmation notification in the program.
Finding the command line interface is a bit different in the more recent Windows 8 variant. First, open the Apps screen, then go to Windows Systems > Command Prompt. Once the program opens, run the same
ipconfig /flushdns command. You should receive a notification confirming that your local DNS cache has been cleared once the process is completed.
Finally, to clear the DNS cache on Windows 10 if your endpoints have this operating system installed, click on the Start button, then go to Computer Systems > Command Prompt.
Once the interface is open, insert the same
ipconfig /flushdns command. You should receive a message in the program confirming you cleared your DNS cache. After this is displayed, you can close the Command Prompt.
How to Clear DNS Cache on macOS
To clear the local DNS cache on your Mac device, you first need to know what version of macOS it is running on. To find this out, click on the Apple icon on the top left-hand side of your desktop, then select About This Mac. The computer’s macOS version will be the first piece of information listed in the pop-up that appears.
After establishing this, you will need to access your Mac’s Terminal interface. This can be found under Go > Utilities > Terminal. Once that’s open, depending on what version of macOS the computer has, you will need to enter a specific command. You can find them all detailed in the sections below.
macOS 10.5 (Leopard)
To flush the DNS cache on macOS 10.5, you will need to insert the following line in your Mac’s Terminal:
sudo lookupd -flushcache
Once this step is complete, you will be prompted to verify your device password and if you manage to do so, the cache should be cleared.
macOS 10.6 (Snow Leopard)
If you are running macOS 10.6, input the following command after opening the Terminal tab:
sudo dscacheutil -flushcache
To finish the process and clear the local DNS cache, make sure to enter your device password when requested to.
macOS 10.7-10.9 (Lion/Mountain Lion/Mavericks)
For macOS versions 10.7 through 10.9, the command that flushes the local DNS cache is:
sudo killall -HUP mDNSResponder
After inserting it into the Terminal program, you will need to, you guessed it, confirm your device’s password to complete the process.
macOS 10.10 (Yosemite)
When it comes to macOS 10.10, you will have to run the following command in your Mac’s Terminal:
sudo discoveryutil udnsflushcaches
Then, make sure to confirm the process with your device password, and your cache should be all set and cleared.
macOS 10.11-10.15 (El Capitan/Sierra/High Sierra/Mojave/Catalina)
For macOS versions that are 10.11 or higher, the Terminal command you need to enter is as follows:
sudo killall -HUP mDNSResponder
After running it, you will be asked to enter your computer’s password. Do as instructed and the device’s local DNS cache should be clear.
How to Clear DNS Cache on Linux
Just like macOS, Linux uses Terminal as a command line interface. To open it, click on the Activities tab in the top left-hand corner of the desktop and type ‘terminal’ in the search bar that pops up. Then, you have to type one of two possible commands in there, depending on what Linux distribution your device is running on.
For Ubuntu, the following command needs to be input into the Terminal:
sudo systemd-resolve --flush-caches
Then, just like on Mac once again, the Terminal program will prompt you to confirm the operation with your password. Do so, and complete flushing the local DNS cache.
In the case of Linux distributions other than Ubuntu, run the following command in the interface to clear the DNS cache:
sudo /etc/init.d/dns-clean start
This time around, you will not need to confirm the operation with a password. After inserting the appropriate command, the process should be finished.
How to Clear DNS Cache on Google Chrome
As mentioned before, DNS records are stored by either the operating system or the browser. Thus, sometimes you might have to flush the DNS cache on your browser instead. To do so in Google Chrome, simply enter the following address in the search bar:
This will lead you to the page pictured below.
Click on the Clear host cache button and Google Chrome’s DNS cache will be flushed.
Performing a regular flush on the local DNS cache on your endpoints is a safe and simple way to not only prevent network connectivity issues but cyberattacks as well. Do you want to take it one step further? A solution such as our Heimdal™ Threat Prevention can help you further enhance DNS security on your endpoints. Sign up for a free 30-day trial and find out how.