How to Flush DNS Cache
If you’re having connection issues, you might want to clear your DNS Cache. This may sound like a complicated and technical process, but it’s much easier than you might think.
In fact, flushing the DNS Cache requires no technical knowledge, especially if you have a detailed step-by-step tutorial to follow.
Download eBook: Speed Up Your Website. 8 Practical Tips That Work
In this article, you’ll learn what a DNS Cache is, why you may need to flush your DNS Cache, and the many different ways to go about it using flush DNS command.
Video Tutorial
Learn how to flush DNS cache and improve your security and connection with our video tutorial.
What Is DNS Cache?
Similar to web browsers, operating systems also store cache files of previous Domain Name System (DNS) lookups in what is called the DNS cache. It consists of compressed information units called resources records (RR) about all visited websites, displayed in ASCII code.
The following are a DNS cache’s components:
- Resource data ‒ contains a record’s description, such as the address and hostname.
- Record type ‒ describes the record’s type (A or AAAA record).
- Record name ‒ showcases the DNS entry’s domain name.
- Time To Live (TTL) ‒ the resource record’s validity time measured in seconds.
- Class ‒ the resource record’s appropriate protocol group.
- Resource data length ‒ refers to the resource data’s value.
When visiting a website for the first time, the user’s’ operating system stores that site’s DNS cache files. It streamlines the DNS lookup process by resolving domains to their IP addresses, making web pages load faster the next time you visit the same IP address.
Reasons to Flush DNS Cache Periodically
Most operating systems perform DNS caching to lessen the DNS servers’ burden during high traffic. Its TTL determines the cache’s validity period. As long as the cache files are still valid, they will answer content requests without going through the DNS server.
Despite this, using corrupt or outdated DNS cache files can lead to errors and security vulnerabilities. Your operating system may store a bad DNS cache when you visit websites that just moved to a new domain name or host. Therefore, we recommend flushing your DNS cache periodically.
Here are the reasons why you should clear your DNS cache regularly:
- To prevent search behavior tracking ‒ storing DNS records makes it easier for hackers to predict your browser history.
- Security ‒ DNS cache files are the main target for DNS spoofing, which endangers users’ sensitive information like login credentials and personal data.
- To solve technical problems ‒ forcing the operating system to search updated DNS records can solve connection issues and incorrectly displayed web content.
How to Flush DNS Cache
Depending on your operating system, the steps to flushing a DNS cache may vary. The tutorial below will show you how to do it on Windows, Linux, and Mac OS X.
Microsoft Windows XP, 7, Vista, 8, 8.1 or 10
On Microsoft Windows flush DNS cache is a relatively simple process. Keep in mind that you need to run as administrator when executing the command prompt to access all system security permissions.
- Press Windows+R keys together and click Run.
- Type cmd to open the Windows command prompt console.
- Type ipconfig /flushdns in command prompt and press enter.
- Your DNS cache files have been cleared and DNS resolver cache reset. If the process is successful, you’ll see the confirmation message on your command prompt:
If you don’t have administrator privileges yet, run the cmd command by pressing Ctrl+Shift+Enter.
MacOS 11 Big Sur or MacOS 12 Monterey
While the steps to flushing a DNS cache on MacOS are simple, you need to run the right flush DNS command based on your current OS version. You can check your MacOS version by clicking on the Apple icon at the top-left corner -> About This Mac.
- Press F4 key, search for terminal im Spotlight search and click enter to open it.
- Enter the following command and press enter:
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
- Enter your admin password if prompted and click enter.
- Your DNS cache is cleared now.
Older MacOS Versions
First, press the F4 key and enter terminal in the Spotlight search field to open the command terminal window, then use the right command for your version of MacOS:
10.11 El Capitan, 10.12 Sierra, 10.13 High Sierra, 10.14 Mojave or 10.15 Catalina:
sudo killall -HUP mDNSResponder
10.10 Yosemite:
sudo discoveryutil udnsflushcaches
10.7 Lion, 10.8 Mountain Lion or 10.9 Mavericks:
sudo killall -HUP mDNSResponder
10.5 Leopard or 10.6 Snow Leopard:
sudo dscacheutil -flushcache
10.5 Leopard:
sudo lookupd -flushcache
Linux
By default, Ubuntu doesn’t cache DNS records. If you manually install a DNS service like name service caching daemon (nscd), the steps below will show you how to flush DNS cache on your computer. Make sure to run as administrator when following these steps.
- Press Ctrl+Alt+T keys together to open the terminal window.
- Enter the following command line to clear DNS cache files on the init.d subdirectory:
sudo /etc/init.d/nscd restart
Here is the guide to flush the DNS cache on a system that uses systemd.
- Press Ctrl+Alt+T keys together to open the terminal window.
- Type the following command line:
systemd-resolve --flush-caches
- Enter the following in the command prompt to check whether or not the previous command has successfully flushed the DNS cache.
systemd-resolve --statistics
Flush Your DNS Cache in Google Chrome
As Google Chrome stores a separate DNS cache from the operating system on your computer, flushing them will have the same benefits. This is particularly important if you use Google Chrome as your main web browser.
Keep in mind that this cache type is different from the browser cache.
Here are the steps to do it:
- Open Google Chrome and enter the following address into its address bar:
chrome://net-internals/#dns
- On the net internal settings page, select Clear host cache.
Conclusion
When experiencing connection issues or seeing incorrectly displayed web pages, your system might be storing corrupted or outdated DNS cache records. You can quickly solve it by using flush DNS command. If doing so doesn’t resolve the problem, try to clear your web browser cache instead.
We hope you find this article helpful in solving DNS server issues. Good luck.
Comments
May 13 2018
To check DNS and IP addresses accessed by Chrome, you can go to: chrome://net-internals/#dns
May 23 2018
Hello, Cesar I appreciate your input. I was not aware of the provided tool and it seems really useful!
July 02 2021
Hello : The article was very good and ilustrative , I didn't know that flushing the cache , prevents to several problems from attacks and stole our credentials. Every day we learn something interesting !! Thank you
January 16 2022
DNS_PROBE_FINISHED_NXDOMAIN I request u to do from your team pls fix it
January 18 2022
Hi there, feel free to check our guide on solving DNS_PROBE_FINISHED_NXDOMAIN error. If you're having any trouble with it, don't hesitate to contact your host - in case you're hosting with Hostinger, you can find how to contact the Customer Success team here :)