38

How is the DNS cache cleared in 22.04?

The method that worked in 20.04:

systemd-resolve --flush-caches

no longer works.

Artur Meinild
  • 31,385

2 Answers2

53

Newer versions of Ubuntu use this syntax (run as root or with sudo):

resolvectl flush-caches 

(This will also work in Ubuntu 20.04.)

Artur Meinild
  • 31,385
  • 2
    I'm on a freshly installed 22.04 and this command did not clear whatever DNS cache dig is using. – Basti Mar 28 '23 at 07:30
  • dig doesn't have a cache. dig queries a nameserver directly. The nameserver is probably caching things, but dig has no control over that. – James Moore Dec 13 '24 at 23:50
17

For Ubuntu 22.04 users, follow the below command to flush DNS Cache(resolvectl) :

resolvectl flush-caches

To check the cache size run the below command:

resolvectl statistics
Stanley
  • 301