How to Flush the DNS Resolver Cache on Debian

In this article, you will learn how DNS cache works and how you can flush it using the resolvectl utility in Linux.

How to Flush the DNS Resolver Cache on Debian

Domain Name System, commonly known as DNS is a critical part of modern web. DNS allows systems to locate and communicate with various resources located around the world.

Once your device requests a website such as, it uses the DNS server (either on your local machine or your ISP) to locate the IP address of the site. In this case, your browser or client can now communicate with the server hosting the site you are looking for.

What is DNS Resolver Cache?

Although this may sound like a trivial job, without DNS, browsing the web would be a more chaotic place than necessary. For example, you'd have to manually remember the IP address of every site you visit.

When you request a new site, your Operating system will make an external DNS request to the available DNS server. In most cases, this is the default ISP server or a custom one such as Google or CloudFlare.

Once the system makes the request, it will cache that result in its local DNS so that it will not have to make an external request the next time you revisit that website.

Although caching the DNS request can be useful, it can lead to errors. For example, if a website moves to a new address and the local DNS entry holds the old address, your system might fail to find the requested resource.

The following image illustrates how DNS Resolver cache works.

As you can see, when the system requests the website, it will first ask the DNS Resolver cache, if it has that address, the request is completed. If not, the client will make a request to an external DNS Server and pass that result to the DNS Cached to be saved for future requests.

Yes, that's how the DNS Resolver cache works.

View DNS Cache Statistics

You can view the statistics for the DNS cache using the the resolvectl command. Run the command as show:

sudo resolvectl statistics

The command will return the statistics for the resolver cache as shown:

DNSSEC supported by current servers: no

Current Transactions: 0
  Total Transactions: 500
  Current Cache Size: 0
          Cache Hits: 321
        Cache Misses: 800
DNSSEC Verdicts        
              Secure: 0
            Insecure: 0
               Bogus: 0
       Indeterminate: 0

In some cases, you may need to use the systemd-resolve command as:

sudo systemd-resolve --statistics

How to Flush the DNS Resolver Cache?

Sometimes you may need to flush the DNS cache for your system. Whether the DNS cache holds an incorrect record or you simply want to start a new cache, you will need to flush the cache.

In this section, we will learn how to flush the resolver cache.


To flush the DNS resolver cache, you will need:

  1. a root user or user with sudo privileges.
  2. termina access.

Flush DNS Resolver Cache Using resolvectl

The best and quickest way to flush DNS resolver cache is using the resolvectl utility. You can run the command as shown:

sudo resolvectl flush-caches

The command will clear the DNS cache from your system.

You can also use the systemd-resolve command:

sudo systemd-resolve --flsh-caches

And that's it.


In this guide, you learned about the basics of DNS, how the DNS cache works and how to flush the cache on a Debian based distribution.

Feel free to explore our library for more tutorials on Linux, Development, Hardware, and more.

Get your GeekBits Badge and cool perks here:

If you enjoy our content, please consider buying us a coffee to support our work:

Table of Contents
Great! Next, complete checkout for full access to GeekBits.
Welcome back! You've successfully signed in.
You've successfully subscribed to GeekBits.
Success! Your account is fully activated, you now have access to all content.
Success! Your billing info has been updated.
Your billing was not updated.