2 methods to clear DNS cache inside operating system... and Google Chrome

Intro

As a web developer, I adjust the DNS records for my domain names often, especially when it comes to server migration and downtime mitigation.

Modern DNS works efficiently through DNS caching mechanism, to reduce network and improve browser/application response time.

However, when you are changing the A record, DNS cache could be a trouble for you. Of course you can change the TTL (time-to-live) value of the record to a smaller value, to make the cache of DNS records expired in a shorter time.

But how about the client-side? We may clear DNS cache manually.

Time is precious, right? :D

A Clock
Photo by Srikanta H. U / Unsplash

How to clear DNS cache in Windows?

  1. Press Win + X and then r on your keyboard
  2. Enter ipconfig /flushdns in the prompt and then press Enter
The prompt
The prompt

Viola! It is very simple to clear DNS cache in Windows, and also in macOS and Linux.

How to clear DNS cache in Google Chrome?

Google Chrome has its own DNS caching pool. You can only clear it through an internal page.

  1. Enter chrome://net-internals/#dns in Google Chrome address bar.
  2. Press that only button.
  3. Profit!

How to clear DNS cache in macOS, MacBook and iMac?

  1. Start the terminal, in your own way (try to ask Siri to do so!)
  2. Paste sudo killall -HUP mDNSResponder;sudo killall mDNSResponderHelper;sudo dscacheutil -flushcache and then press Enter on your keyboard
  3. Type your password and then press Enter
  4. Done

How to clear DNS in Ubuntu?

  1. Start the terminal, in your own hacker-style way!
  2. Paste sudo systemd-resolve --flush-caches and then press Enter
  3. Type your password and then press Enter
  4. Done!