How to Flush or Clear DNS Cache on Ubuntu Linux

|

|

Ubuntu’s DNS cache is a temporary database storing records of recent internet domain visits. If corrupted, it may hinder domain name resolution. Users can rectify this by clearing the cache using specific commands. Ubuntu uses systemd-resolved for network name resolution and caching. If internet connection issues or browser problems arise, users should consider clearing their…

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.

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

Ubuntu uses systemd-resolved, which provides network name resolution to local applications. In addition, 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 and your web browser stored caches.

Before flushing the 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

Transactions
Current Transactions: 0
  Total Transactions: 30

Cache
  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 know the size of the DNS cache, 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 could also use the commands below. Or just all the commands listed here to perform a thorough cleanup.

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

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

Now, clear your browser cache to ensure you can access network domains and other websites.

I hope this post helped you clean your Ubuntu desktop DNS cache.

You may also like the post below:

Like this:



3 responses to “How to Flush or Clear DNS Cache on Ubuntu Linux”

  1. Mario Avatar
    Mario

    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
    root@simon:~#

    1. Arvind Subrmanian Avatar
      Arvind Subrmanian

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

  2. Mehonidas Avatar
    Mehonidas

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

Leave a Reply to Mehonidas Cancel reply

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

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