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 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 below method to flush your DNS,

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 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+.

Suggested Read:  How to install µPad (MicroPad) on Ubuntu - Open source note taking app

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

You may also like...

1 Response

  1. infometr says:

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

Leave a Reply

Your email address will not be published. Required fields are marked *