For example, when I type in https://lonezscents.com/ in my browser’s address bar for the first time, the browser has to ask DNS servers where to find the site. Once it has that information, the browser can store it in its local cache. Then, the next time I type in that website address, the browser will look for its DNS information in the local cache first and be able to find the site more quickly.
The problem is that sometimes dangerous IP addresses or corrupted results can be cached and need to be removed. The DNS cache can also impact your ability to connect to the internet or cause other issues. Whatever the reason, all major operating systems allow you to force the process of clearing this cache — or “flushing DNS.”
In this post, we’ll cover everything you need to know, including:
Flushing DNS will clear any IP addresses or other DNS records from your cache. This can help resolve security, internet connectivity, and other issues.
It’s important to understand that your DNS cache will clear itself out from time to time without your intervention. That’s because the DNS cache — in addition to saving all information that’s relevant to identifying and finding a website — also saves a component called TTL, or time to live. This specifies a period of time (in seconds) in which the DNS record for a site remains valid. Within this time period, any queries to the website are answered from the local cache without the help of the DNS server. Once the TTL expires, the entry will be removed from the cache.
However, there are reasons you may need to force a DNS flush rather than wait for the TTL of all the entries to expire. Let’s take a look at why below.
Why would you flush DNS?
There’s a few reasons you might need to flush your DNS cache. These reasons may have to do with security, technical problems, or data privacy. Let’s briefly cover each one below.
1. You want to prevent DNS spoofing.
DNS spoofing — also known as DNS cache poisoning — is an attack in which bad actors gain access to your DNS cache and alter the information in order to redirect you to the wrong sites. In some cases, they will redirect you to a fraudulent website that resembles its intended destination so that you enter in sensitive information, like your online banking login information.
2. You’re seeing a 404 error.
Let’s say you’ve cached the DNS information of a site that’s since moved to a new domain name or host. In that case, the DNS information on your computer may not get updated right away and you could end up seeing a 404 error or an outdated version of a site when you try to visit. Although the information will eventually get updated in your DNS cache, you don’t have to wait. You can clear DNS cache at any time.
3. You’re having trouble accessing a website.
If you’re having trouble getting a website to load, then you should try other steps first, like clearing your browser's temporary files and cookies and adjusting your browser settings to turn off pop-up blockers and allow sites to save and read cookies. But if you’ve exhausted your options, then you can flush DNS to reset your computer's connection to the internet.
4. You want to keep your search behavior private.
When you think of tracking user behavior on the internet, you probably think of cookies — but the DNS cache can reveal your search history as well. That’s because the DNS cache is designed to act like a virtual address book, storing the information of the websites you visit regularly. To keep this information away from data collectors or bad actors on the web, it’s a good idea to regularly flush your DNS cache.
Now that we understand what flushing your DNS cache means and why you’d want to, let’s walk through how you can do it below.
How to Flush DNS
The process for flushing DNS varies depending on your computer’s operating system. Let’s go over the process for the major systems below.
How to Flush DNS Windows 10
Here’s the processing for flushing your DNS cache on Windows 10. These steps should also work for Windows 8.1
1. Click the Start button. It’s the Windows logo in the bottom left corner.
5. If you are asked for an administrative login at this point, then you’ll need to contact your system administrator to proceed.
6. In the command prompt window, type ipconfig /flushdns.
7. Press Enter.
8. You should see a message confirming that the DNS Resolver Cache was successfully flushed.
How to Flush DNS Windows XP and Vista
The process for flushing your DNS cache on Windows XP and Vista is nearly identical to that of Windows 7. However, the message at the end varies and may require admin intervention.
1. Click the Start button. It’s the Windows logo in the bottom left corner.
2. Click All Programs > Accessories.
3. Select Command Prompt.
4. In the command prompt window, type ipconfig /flushdns.
5. Press Enter.
6. You should see a message confirming that the DNS Resolver Cache was successfully flushed. If you receive a message that says “Action Requires Elevation” instead, then you need to contact the admin of your computer to complete the steps above.
How to Flush DNS Mac OS X
The process for flushing your DNS cache on a Mac computer is similar, no matter what software version it’s running. But you will need to know what version for step 6 since the command prompt varies.
1. Open Finder.
2. Click Applications.
3. Scroll down to the Utilities folder and click it.
4. Open Terminal.
5. To open Terminal, you could also simply open Launchpad and type in “Terminal” in the search bar.
6. In the Terminal window, type in the one of the following commands based on your software version:
10.7-10.9, 10.11-10.14 (Lion, Mountain Lion, Mavericks, El Capitan, Sierra, High Sierra, Mojave): sudo killall -HUP mDNSResponder
8. You should see a message confirming that the DNS cache has been reset.
Note: The screenshots in this section are my own.
How to Flush DNS Google Chrome
Google Chrome is not an operating system of course, but it does keep a DNS cache of its own. This is separate from your operating system’s cache and from Chrome’s browser cache. If Chrome is set as your default web browser, then you’ll need to clear Chrome’s DNS cache as well as your operating system’s DNS cache. Here’s the process.
1. Type in the following address into your browser’s address bar: chrome://net-internals/#dns
2. Click the Clear host cache button.
Note: The screenshot in this section is my own.
How to Flush DNS Linux
Unlike Windows and Mac computers, Linux systems don’t have a DNS cache by default. However, each distribution might use a different DNS service to store DNS records locally. Depending on the service, you can either clear the cache or restart the service.
1. Press Ctrl+Alt+T on your keyboard to launch a terminal window.
2. In the Terminal window, type in the one of the following commands based on the service your Linux system is running.
NCSD: sudo /etc/init.d/nscd restart
Dnsmasq: sudo /etc/init.d/dnsmasq restart
BIND: You may have to try multiple commands:
sudo /etc/init.d/named restart
sudo rndc restart
sudo rndc exec
3. You may be asked to enter your password.
4. The service might stop, then start again before sending a confirmation message that the cache was successfully reset.
Flushing Your DNS Cache
There’s a lot of reasons to regularly flush your DNS cache. It can help prevent phishing schemes or other attacks on your computer, direct you to the most up-to-date versions of your most frequently visited sites, restore your internet connection, and keep your data private.
The best part is how easy the process is. Following the steps above can help you perform a DNS flush quickly and easily, no matter what operating system your computer has. That way, you can move onto your other website development tasks.
Originally published Feb 19, 2021 7:00:00 AM, updated December 03 2021