Your device’s DNS cache lets you visit your favorite websites without having to go through DNS resolution every time — but if your DNS records are outdated, you could run into connectivity issues. Read on to learn how you can flush DNS records to clear your DNS cache.
Contents What is the DNS cache? How does a DNS cache work? What happens when you flush DNS? How to clear DNS cache entries How to clear DNS cache entries on macOS How to clear DNS cache entries on Windows How to clear DNS cache entries on Linux How to clear DNS cache entries on Google Chrome Why would you want to flush DNS? Frequently asked questions
What is the DNS cache?
A Domain Name System (DNS) cache is a record of all the queries made to DNS servers by your device. To understand the role it plays in internet communications, we need to dive a little deeper into what DNS is and what it does. To connect to a server over a network, your device needs to know its Internet Protocol (IP) address. You could simply enter the IP address by hand, but there’s a small problem — IP addresses are composed of long strings of numbers. And most brains just aren’t equipped to handle long sequences of numbers. That’s where the Domain Name System comes in. The DNS is a special database that matches domain names to IP addresses. When you type a new web address into your browser, your device first queries its assigned DNS server, only initiating the connection to your desired website once it has the address in hand. And to prevent repeat requests, successful past DNS queries are stored in the DNS cache.
How does a DNS cache work?
A DNS cache works just like any other cache — it reserves space on your device to store DNS records that may be required again in the future. Before querying a DNS server, your device will check its DNS cache and, should it find a matching record, connect to the IP address it had stored in its memory. DNS caching greatly speeds up communications because you don’t have to go through DNS resolution every time you want to visit the same website. Because the structure of the internet is fluid, with new servers springing up and old ones getting decommissioned every day, DNS records are rarely permanent. The life expectancy of a DNS entry is measured in seconds and is known as its “Time to Live” (TTL). The entry’s TTL value is set by the DNS server and measured in seconds — once the time is up, the record will be automatically purged from the device’s DNS cache.
What happens when you flush DNS?
When you flush DNS from the cache, you manually expunge all held DNS records from memory regardless of their remaining TTL. By flushing your DNS cache, you’re basically telling your device that it needs to go through DNS resolution again and obtain new IP addresses for the websites that you used to visit. {SHORTCODES.blogRelatedArticles}
How to clear DNS cache entries
All major operating systems and browsers support DNS cache clearing. The instructions below will teach you how to flush DNS cache entries on macOS, Windows, and Linux devices, as well as the popular Google Chrome browser.
How to clear DNS cache entries on macOS
Press the smiling blue face icon to open “Finder” and click on “Applications.”Open the “Utilities” folder and launch “Terminal.” Based on your OS, type in the appropriate command to flush DNS records: Tiger (10.4): lookupd -flushcacheLeopard (10.5): sudo lookupd -flushcacheSnow Leopard (10.6): sudo dscacheutil -flushcacheLion (10.7), Mountain Lion (10.8), Mavericks (10.9): sudo killall -HUP mDNSResponderYosemite (10.10): sudo discoveryutil mdnsflushcacheEl Capitan (10.11), Sierra (10.12), High Sierra (10.13), Mojave (10.14), Catalina (10.15): sudo killall -HUP mDNSResponderBig Sur (11), Monterey (12), Ventura (13): sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponderEnter your password and press “Enter.” If you are successful, you will see a message stating that you’ve reset your DNS cache.
How to clear DNS cache entries on Windows
To flush DNS records on a Windows device, you will need to use the command prompt. The process is nearly identical for Windows XP, Windows Vista, Windows 7, and later Windows OS. Simply follow these steps: Click the “Start” button in the bottom-left corner of your screen. Open the command prompt: Windows 10, Windows 11: Select “Command prompt” directly from the list. Windows XP, Windows Vista, Windows 7, Windows 8: Click “All programs,” select “Accessories,” and choose “Command prompt.”In the command prompt window, type the following command: ipconfig /flushdns.Press “Enter” to confirm. If you are successful, you will see a message stating that the DNS resolver cache has been flushed.
How to clear DNS cache entries on Linux
The Linux operating system doesn’t come with DNS caching capabilities by default — this feature is implemented differently by each distribution. Here is what you need to do to clear DNS records on the most popular versions: Open the terminal by pressing Ctrl, Alt, and T simultaneously.Based on your distribution, enter the following command to flush DNS: Ubuntu: sudo systemd-resolve –flush-cachesNCSD: sudo /etc/init.d/nscd restartDnsmasq: sudo /etc/init.d/dnsmasq restartBIND: sudo /etc/init.d/named restartIf prompted, enter your password to confirm that you want to flush DNS cache records.
How to clear DNS cache entries on Google Chrome
Browsers have their own DNS caches, separate from your operating system. If you flush DNS on your device but not your browser, you could still end up using outdated DNS records while browsing. Here’s what you need for a clean start on Google Chrome: Open Google Chrome on your device. Enter the following in the address bar: chrome://net-internals/#dnsClick “Clear host cache” to flush DNS records.
Why would you want to flush DNS?
While DNS caching can greatly improve your online experience, there are also practical benefits to periodically flushing DNS. Here are a few good reasons why you’d want to flush your DNS cache at least once in a while. Avoiding DNS spoofing. DNS spoofing refers to a wide range of cyberattacks that rely on altering the entries held on DNS servers to redirect victims to fake websites. The malicious DNS entries are distributed to the victims’ devices as part of the DNS resolution process and stored in their DNS cache. If your DNS server operators catch wind of what is going on, they will restore the proper values from backups — in that case, flushing your DNS cache will delete the bad entry from your system and let your device fetch a new one.Avoiding DNS cache poisoning. DNS cache poisoning is a specific type of DNS spoofing that exploits the DNS lookup process. When a DNS server doesn’t have the requested DNS record on hand, it may query more authoritative servers for additional information. At this point, the hackers can bombard the DNS server with bogus responses to trick it into accepting the fake value as legitimate. Storing this value “poisons” the DNS resolver cache — the bad entry will now be returned to victim devices as part of DNS resolution. Just like with DNS spoofing, flushing your DNS cache will clear any compromised records and allow your device to request new values.Clearing out old DNS entries. Some DNS records simply outstay their welcome. If a website’s IP address changes before the associated DNS record’s TTL expires, you could end up running into a wall of “server IP address could not be found” errors while trying to connect. To get the website’s new IP address, flush your DNS cache and enter the desired web address into your browser — your device will query the DNS server again, potentially netting you the new value.Switching to a new DNS server. Most people use the default DNS server assigned to them by their internet service provider (ISP), but that’s not often their best option. ISP-assigned DNS servers may hold outdated information, block certain websites, or even compromise your privacy (because your ISP can see which DNS queries come from which IP address). As a result, many people switch to private DNS providers — but if they forget to flush DNS cache records after they change DNS servers, they’ll be stuck using their old DNS provider’s entries until the latter’s TTL expires.Clearing private information. Just like your browsing history, your DNS cache stores information about where you’ve been online — after all, you wouldn’t have a DNS record if you didn’t try to visit the associated website. This private information can be dangerous in the wrong hands, such as criminals wishing to study your habits for a spear phishing attack. Periodically flushing your DNS cache prevents this sensitive data from accumulating.
It is perfectly safe to flush your DNS cache at any time — the process will not harm any software or hardware. The only possible downside is that you will have to go through DNS resolution again for every website, but even this drawback will quickly disappear as you replenish your DNS cache with fresh records. ), }, { question: ‘How often should you flush the DNS cache?’, answer: ( There is no hard and fast rule for flushing DNS. Some people only flush the DNS cache when they encounter 404 errors, while others clean it out daily for a better browsing experience. Keep in mind that other than slight delays when accessing websites for the first time, there are no downsides to flushing DNS regularly. ), }, { question: ‘Does clearing your DNS cache increase your internet speed?’, answer: ( Flushing DNS does not impact your internet connection speed at all — although it may feel like it does. For example, if you were holding on to outdated DNS records, you might have had issues connecting to some websites, greatly slowing down your browsing experience. After you flush the DNS cache, you’ll be able to get the right IP addresses and connect much more smoothly. ), }, ]} />