When you’re trying to diagnose any problem associated with your computer’s active internet connection, one of the simplest and most frequently used steps in that process is the flushing of the DNS cache for either Mac or Linux. This tends to liberate your web-dependent applications from errors and obstructions in code and stored data. However, it’s not a function that can be found with the click of a single button, and you won’t find it in most troubleshooting menus. It’s an operating system command that’s going to change depending on which operating system you’re using. Windows? Mac? Linux? They’re all different, and no matter which of those three you work on most often, it’s useful to know them all.
Therefore, we’re going to show you how to flush the DNS cache on your computer regardless of which operating system you’re using. If you’re the type of person who regularly diagnoses and repairs networking errors, it’s information that you’ll want to have!
Of course, the fact that you don’t regularly have to interact with the DNS cache on your computer (at least, not directly) means that you might not even know what it does. After all, like many processes your computer is built to perform, everything involving the DNS occurs mostly in the background. That said, almost every online activity your perform—especially those in a web browser—utilize the DNS.
What is the DNS? It’s the acronym for Domain Name System, and though we’ll talk about it a bit more extensively in the article below, you can basically think of it as a phone book for the entirety of the internet. When you type in the URL of your favorite website, your browser isn’t going to know where to go by the name alone. Instead, it’s going to use this “phone book” of a sort to find the necessary address to pull up the assets of the website you’re trying to visit.
Sound complicated? It is, but it’s also largely automated thanks to the operating systems we use, combined with our modern routers and computer hardware. Count your blessings, for that fact.
Even though it’s mostly automated, that doesn’t mean that it always knows how to fix itself. When the DNS cache on your machine becomes “poisoned,” it can cause all kinds of havoc that is difficult to repair without flushing the entire cache.
Lucky for you, that’s exactly what we’re going to show you how to do.
Before we get started, it should be said that flushing the DNS cache isn’t a “fix all” solution for every type of online networking problem that you have. However, it’s a relatively harmless troubleshooting step that you can feel free to perform whenever you’re having errors online. Though we’ll attempt to be comprehensive below, flushing the DNS cache should usually be followed up with a sweep from your antivirus or anti-malware software.
What is the DNS Cache?
As we’ve already said above, the closest analogy that we can provide for the DNS (Doman Name System) is a “phone book for the internet.” However, it doesn’t consist of millions of different URLs. Instead, it’s made up largely of IP addresses.
When you call up a website with your browser, the process usually goes something like this. Your browser sends the URL to your router. Based on your computer’s settings, your router will be assigned a specific DNS library, to use as a reference. Using that DNS, your router will match the URL you’ve input with the IP address of the appropriate website. After that’s achieved, your browser will know what information and data to display, after it’s been retrieved through your active internet connection.
And you thought typing in http://www.facebook.com was a simple thing. Hah!
Flushing the DNS Cache
Where does the DNS cache fit into the picture, then? As you continually visit more and more websites, your computer will store the DNS information for the websites that your visiting. It allows you to more quickly access sites that you’ve already been to; those with DNS information stored in the cache.
If this system is working properly, the only thing that it does is give you faster, more responsive online activity. It’s largely an artificial speed—your computer just knows how to look up information faster—but it’s welcome, just the same. However, when the DNS cache encounters corrupted code or unauthorized IP addresses.
In essence, it’s as if a bunch of bad information has been cataloged in your “phone book.” As a result, the entire collection of data becomes obfuscated. Usually, this manifests first as your browser behaving like you’re not connected to the internet. It either perpetually tries to load websites, or flat out tells you that the DNS information couldn’t be retrieved.
Either way, that’s no good.
Even when this problem is caused by a virus or malicious software (malware) you can still remedy the damage by flushing the DNS cache. That’s accomplished, finally, through the following steps.
In Windows, the whole process is remarkably simple. If we’re being honest, it’s simple in all three of the operating systems that we’re looking at today, but Windows users are going to have the easiest time.
- First, pull up the Windows Command Prompt. Click on the Start Menu, followed by Run. Then, enter cmd. Know that if you’re using Windows 8 or 10 (and why wouldn’t you be?) you can simply use the Search Bar and type in the same command.
- This will bring up the Command Prompt, which we’ll use to flush the DNS cache.
- Type ipconfig /flushdns
- After, you should be told that DNS cache has been successfully flushed.
- Close the Command Prompt, and go back to your browsing!
After you’ve performed these few, basic steps, your computer is going to have to seek new DNS information for every website that you visit. Will it seem slower? Probably not in a noticeable way, unless you’re using a slow internet connection. As we said above, you’ll want to follow up a DNS cache flush with a sweep from your antivirus and anti-malware software.
The process is going to be fairly easy on your Mac, too. Apple’s computers might have a slightly smaller install base than Windows, but that doesn’t make Mac OS X any less fantastic of an operating system.
We’re going to assume that you’re using the most recent version of it, too. That means that you should be upgraded to Mac OS X Yosemite, version 10.0 or higher. If you’re using an older version of Mac OS X, follow this link for further instructions on how to flush the DNS cache. For real, though; update your darned operating system!
- Access the Terminal window, by going through /Applications/Utilities.
- Within the Terminal application, enter the following line of code: macbook$ sudo discoveryutil udnsflushcaches
- In the following line, type logout, and then press Enter to exit the Terminal application.
With this completed, your DNS cache should be flushed, and you should be able to get back to your browsing!
Let’s face facts—far fewer people are using Linux than practically any other operating system out there. That said, it certainly has its place, especially within network and server protocols. If you work regularly with either of these, it can be extremely handy to know how to flush the DNS cache in Linux.
However, this is also where things can become slightly complicated. There are quite a few different distros (distributions) of Linux currently in use, and they’re all going to use the DNS cache in slightly different ways. If your Linux distro uses the Name Service Caching Daemon (NSCD), you can still flush the cache with relative ease.
- In the Command Terminal, enter [local]$ sudo service nscd restart
- This will instruct the DNS resolver cache to restart, thereby “flushing” the cache on your server.
Easy-peasy, right? Things can get a little bit more complicated on certain Linux distros, so if the above command doesn’t work, be sure to look for instructions for the specific one that you’re using.
Troubleshooting the DNS
Of course, the end result of all of this trouble is ideally a resolved connection issue. If you were having trouble connecting to websites, or if you were receiving DNS lookup errors, this more than likely fixed the problem.
If it didn’t, however, there might be a problem with your network’s router hardware. After giving your computer a thorough search with antivirus and malware removal tools, try restarting your router hardware, to see if it resolves your DNS lookup issues.
We hope that the above instructions have helped you to flush the DNS cache on your Windows, Mac, or Linux computer. Not only that, we also hope to have taught you a little bit about how DNS works. After all, learning how to fix a problem is only half of the solution, if you’re not aware of what might have been causing it in the first place. If you have any remaining questions about this topic or anything else DNS-related, be sure to let us know in the comments below!