If you're having issues connecting to certain websites, it's probably time to clear your DNS cache. In this post, we'll cover exactly how to flush your DNS cache and why it actually matters...
What is the Domain Name System (DNS)?
The Domain Name System (DNS) is a naming system for devices or services connected to the internet which converts domain names into IP addresses.
The DNS cache present in your device contains all the domain names converted into IP addresses, which makes accessing them faster because it is no longer necessary to process the conversion every single time a request to websites you've already visited is made. However, sometimes it can be useful to flush this cache – keep reading to find out how...
The Benefits of Periodically Flushing Your DNS Cache
The answer to some common problems you might face when building and setting up new sites and changing domain names can be flushing the DNS cache on your device locally.
Here's why regularly clearing your DNS cache is important:
- For Security
Your DNS cache files are the main target of DNS Spoofing, which is a type of attack that alters DNS records in order to redirect online traffic to a fraudulent website that resembles its intended destination. This is dangerous because you may unknowingly be passing on your personal information (such as login credentials or even payment information) to this fake website.
Flushing your DNS cache empties it of most files (except those related to automatic updates), which significantly reduces the chances of this happening...
- To Resolve Bad Connections
If your website doesn’t load on a particular device but loads on other devices, it’s most likely due to DNS caching issue.
By flushing your DNS cache, the wrong IP address entry will be removed and the right/up-to-date IP address will be used when the next request is made.
- Remove Old DNS Data
Since there are a number of popular DNS providers, such as DNS Made Easy or Cloudflare – you might run into problems if you’ve recently changed your DNS provider but your cache still contains the data with the data from your old DNS provider – like the websites that you’ve been accessing regularly.
When this is the case, your devices will still be using the old records instead of the new records which can be resolved by flushing your DNS cache.
- Maintenance
Another benefit of flushing the DNS cache is that it is good practice for maintenance. Although DNS cache files don’t take up a lot of space, the list obviously does grow quickly over time if you don’t flush the cache regularly.
By flushing the cache, records can be properly expunged so resolvers will no longer use now out-of-date information and you can resolve 404 errors you encounter when trying to access certain sites.
When Do I Need To Flush My DNS Cache?
We recommend clearing your DNS cache fairly frequently, especially when performing site migrations (changing DNS servers) or when you're specifically experiencing issues such as not seeing changes propagate when a site migration is supposedly complete.
Even if this is not the case, any outdated DNS cache files might expose you to security vulnerabilities, so our recommendation is to flush the DNS cache occasionally...
How Do I Flush My DNS Cache on macOS?
Here is how to flush your DNS cache on the different version of macOS:
- Press the F4 key, enter Terminal in the Launchpad’s search field to open the terminal window, or go to Applications, click Utilities, and then Terminal.
- Type one of the following commands depending on the macOS version that you are using and press Enter to flush the DNS cache...
- Mac OS X Yosemite - sudo discoveryutil udnsflushcaches
- Mac OS X Snow Leopard - sudo dscacheutil -flushcache
- Mac OS X Leopard - sudo lookupd -flushcache
- Mac OS Sierra, X El Capitan, X Mavericks, X Mountain Lion, or X Lion - sudo killall -HUP mDNSResponder
How Do I Flush My DNS Cache on Windows?
Here is how you can flush DNS cache on Windows XP, Vista, 7, 8, 8.1 and 10.
- Open the Command Prompt
- Windows XP: Open the Start Menu and click Run. Then, type in cmd and press Enter.
- Windows Vista/7: Type cmd in the search bar and press Enter.
- Windows 8, 8.1, and 10: Press the Windows logo key and X on your keyboard. Then, click on the Command Prompt.
- Flush DNS
- Type ipconfig /flushdns and press Enter.
How Do I Flush My DNS Cache on Linux?
By default, Ubuntu does not cache DNS entries. However, if you have manually installed a DNS service, such as name service caching daemon (nscd), then you can periodically flush the DNS cache. The method provided below will show you how you can flush your DNS cache.
- Press Ctrl+Alt+T together to open the terminal window.
- The next step is to enter the following command to clear DNS cache files on init.d subdirectory: sudo /etc/init.d/nscd restart.
Conclusion
The purpose of the DNS cache is to accelerate the browsing process by assigning a domain name to an IP address. However, if it’s not properly maintained, your DNS cache can prevent you from accessing web pages or temporarily prevent you from accessing your own site after changing DNS records or provider entirely.
For this reason, it’s important that you flush the DNS cache periodically.
Thankfully, the steps for flushing the DNS cache for macOS, Windows, and Linux are easy to follow. If this doesn't resolve your issue – you might also need to clear your browser cache...
A note about tutorials: We encourage our users to try out tutorials, but they aren't fully supported by our team—we can't always provide support when things go wrong. Be sure to check which OS and version it was tested with before you proceed.
If you want a fully managed experience, with dedicated support for any application you might want to run, contact us for more information.