linux,

How to Flush DNS Cache from the CLI

Feb 25, 2022 · 1 min read · Post a comment
How to Flush DNS Cache from the CLI

Clearing the DNS cache usually fixes issues related to not resolving new or updated existing domain records. Let’s see how it’s done from the command line though.

Prerequisites

  • Shell environment

Linux

sudo systemd-resolve --flush-caches

Note: The command above is related to Ubuntu-based distros, and for the rest try with one the following alternate commands:

sudo /etc/init.d/dns-clean start
sudo /etc/init.d/nscd restart
sudo /etc/init.d/dnsmasq restart

MacOS (Monterey)

Open Terminal and run the following command:

sudo dscacheutil -flushcache
sudo killall -HUP mDNSResponder

Note: If you are not using the latest version of MacOS (Monterey), just execute the second command.

Windows

Open CMD or PowerShell and run the following command:

ipconfig /flushdns

Conclusion

Nothing much to add to be honest, but if you got something please leave a comment below.
On a side note, follow our official channel on Telegram.