Contents

Clearing your DNS cache

phonebook of the internet.

The Domain Name System (DNS) acts as the internet’s phonebook, translating human-readable website names into the numerical IP addresses that computers use to locate servers. Every time you visit a website, your operating system stores a local copy of that DNS lookup so it can return the address faster the next time you visit. This temporary storage is called the DNS cache. While convenient, the cache can occasionally hold outdated or corrupted information, causing connection problems or redirecting you to the wrong site. Clearing the DNS cache regularly is a simple maintenance task that ensures your browser always has the freshest data.

In the early days of the internet, hosts files were manually maintained lists that mapped domain names to IP addresses. As networks grew, keeping these lists updated became impossible. Paul Mockapetris proposed the Domain Name System in 1983 to solve this problem by distributing the lookup process across servers around the world. DNS relies heavily on caching: once a resolver receives an answer, it saves the result locally for a certain amount of time, known as the Time To Live (TTL). This design speeds up web browsing but sometimes leads to stale data when servers change IP addresses.

  1. Fix site access issues: If a website recently changed servers or DNS records, your local cache may still point to the old address, resulting in errors.
  2. Improve privacy: Clearing the cache removes stored domain lookups, which can reveal a history of visited sites.
  3. Flush malicious entries: Malware or adware can sometimes poison your cache with incorrect records. Refreshing it removes these entries.
  • Ensures you reach the most current version of a website.
  • Helps diagnose connection issues by forcing a new lookup.
  • Removes potentially malicious or hijacked records.
  • The first visit to a site after clearing the cache may be slightly slower, as the system needs to look up the domain again.
  • Repeatedly clearing the cache can increase network traffic because it bypasses the efficiency of caching.
  1. Press Win + R, type cmd, and press Enter to open the Command Prompt.
  2. Run the following command:
    ipconfig /flushdns
  3. You should see a message confirming that the cache was successfully cleared.
  1. Open the Terminal app from Applications > Utilities.
  2. Enter the following command and press Enter:
    sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
  3. Type your administrator password if prompted. The command runs silently, but the cache will be cleared.

Linux distributions use different caching services. Here are a few common examples:

  • Systemd Resolved (Ubuntu 18+):
    sudo systemd-resolve --flush-caches
  • nscd:
    sudo /etc/init.d/nscd restart
  • dnsmasq:
    sudo service dnsmasq restart
  1. Schedule periodic flushes: For frequently used systems, clearing the cache once a month can prevent stale entries.
  2. Automate with a script: Use a small shell or PowerShell script to flush the cache automatically when you reboot.
  3. Verify your DNS settings: After clearing, test your DNS configuration using tools like nslookup or dig to confirm that queries resolve correctly.
  4. Combine with browser cache clearing: If you encounter persistent loading issues, clear both your DNS cache and your browser’s cookies and history.

Flushing your DNS cache is a quick and effective way to resolve browsing problems, enhance privacy, and remove potentially malicious records. By understanding how DNS caching works and knowing the commands for your operating system, you can keep your network connections running smoothly. Make it a regular habit, and you’ll spend less time troubleshooting and more time enjoying a responsive, reliable internet. \nRegularly clearing your DNS cache also helps reduce troubleshooting time when troubleshooting network issues at work or at home. It is a best practice for administrators and everyday users alike. By following the steps above, you can keep your browsing secure and minimize confusion when websites update their addresses.