How to Flush or Clear DNS Cache (Records) on Ubuntu 16.04 | 18.04

programmer 1653351 640

Ubuntu DNS cache (resolver cache) is a temporary database that contains records of all the recent visits and attempted visits to websites and other internet domains.

DNS cache may become corrupt at some point and may prevent you from resolving websites and other internet domain names if that happens. When that happens, the most common way of resolving the issues is clearing the temporary cache database.

Ubuntu uses systemd-resolved, which is a system service that provides network name resolution to local applications. It implements a caching and validating DNS/DNSSEC stub resolver and responder.

So, if you’re experiencing weird Internet connection issues or browsers not working opening some websites and domains, you may want to clear your DNS cache as well as your web browser stored caches.

This brief tutorial shows students and new users how to clear or flush DNS cache database on Ubuntu systems. When you’re ready to flush Ubuntu DNS cache, follow the steps below:

Before flushing Ubuntu DNS cache, you may want to run a report of the current cache size. To do that, run the commands below.

sudo systemd-resolve --statistics

That should display the DNS statistics showing you all the cache in its database.

DNSSEC supported by current servers: no

Current Transactions: 0
  Total Transactions: 30

  Current Cache Size: 14
          Cache Hits: 16
        Cache Misses: 14

DNSSEC Verdicts
              Secure: 0
            Insecure: 0
               Bogus: 0
       Indeterminate: 0

Flushing Ubuntu DNS Cache

Now that you now the size of the DNS cache, simply run the commands below to clear or flush the cache.

sudo systemd-resolve --flush-caches

If the above commands didn’t flush the DNS cache, you can also use the commands below. Or just all the commands listed here to perform a thorough clean up.

sudo /etc/init.d/dns-clean restart
sudo /etc/init.d/networking force-reload

Now go and test to see if your system DNS caches are gone.

Now also clear your browser cache if to make sure you’re able access network domains and other Internet websites.

Hope this post helped your cleaning your Ubuntu desktop DNS cache.

You may also like the post below:


  1. root@si:~# systemd-resolve –flush-caches
    systemd-resolve: unrecognized option ‘–flush-caches’
    root@si:~# lsb_release -a
    No LSB modules are available.
    Distributor ID: Ubuntu
    Description: Ubuntu 16.04.6 LTS
    Release: 16.04
    Codename: xenial

    1. Arvind Subrmanian

      Getting same above error.
      systemd-resolve: unrecognized option ‘–flush-caches’

  2. Yes same her for Ubuntu 16.04:
    systemd-resolve: unrecognized option ‘–flush-caches’

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.