How to fix

How to flush DNS cache in Ubuntu / Debian / Linux Mint


The Domain Name System (DNS) is a hierarchical decentralized naming system. It’s used for computers, services, or other resources connected to the Internet or a private network.

It associates various information with domain names assigned to each of the participating entities. Most prominently, it translates more readily memorized domain names to the numerical IP addresses. It’s needed for locating and identifying computer services and devices with the underlying network protocols.

Since DNS is a decentralized network, we need caches to store domains’ information. All caches should be synchronized. And it’s not easy: the global DNS table changes all the time. So sometimes we need to flush our local cache to refresh it (get a new copy of cache from upper server).

Install and restart nscd to flush DNS cache:

sudo apt install nscd
sudo service nscd restart

– now your DNS cache is empty. All next DNS-resolve requests will get from your primary DNS-server (name server).

Also you can see your current cache state

sudo nscd -g

Or you can do the same by this command:

sudo strings /var/cache/nscd/hosts