How to Flush DNS cache in Ubuntu

DNS Cache stores the IP Addresses of Web Servers that host the website. Some times you need to Flush, Reset or clear your DNS cache to resolve the new ip address of your favorite website or to take effect /etc/hosts file changes.

Flush DNS cache in Ubuntu

Flush DNS using systemd :

Open your terminal app and type the below command and hit enter.

sudo systemd-resolve --flush-caches

You can check you status of your current cache size using the below command in terminal.

sudo systemd-resolve --statistics

Flush DNS using dns clean:

To flush DNS cache on ubuntu, you need to open terminal and run the below command.

sudo /etc/init.d/dns-clean restart

or

sudo /etc/init.d/networking force-reload

This should work very well on Ubuntu 14.04 LTS and later. If it is not working for you , can try the above method to flush your DNS,

Flush DNS using nscd:

For older versions you need to install nscd (Name Service Cache Daemon). Name Service Cache Daemon is a daemon which handles passwd, group and host lookups for running programs and caches the results for the next query. You should install this package only if you use slow Services like LDAP, NIS or NIS+.

Also Read:  How To Encrypt Directories with eCryptfs in Ubuntu

To install nscd on ubuntu, you need to open a terminal and run the below command.

sudo apt-get update

Then type the below command and hit enter to install the nscd.

sudo aptitude install nscd

To flush DNS cache, open terminal and run the below command.

sudo /etc/init.d/nscd restart

If you want to uninstall nscd just run the below command in terminal.

sudo aptitude remove nscd

Watch Video:

If you liked this article, please subscribe to our YouTube Channel. You can also stay connected with us on X (Twitter) and Facebook.



This Post Has One Comment

  1. infometr

    Hey, great post, really well written. You should post more about this.

Leave a Reply