How to Flush the DNS Cache on Debian 10

To flush DNS cache in Debian GNU/Linux use command:

sudo systemd-resolve --flush-caches

If you get error message: “Failed to flush caches: Unit dbus-org.freedesktop.resolve1.service not found.“, enable the service on your system:

sudo systemctl enable systemd-resolved.service

Then again run the “systemd-resolve –flush-caches” command.

You can then check the statistics in order to make sure that your cache size is now zero, thus cleared. Run the following command in order to view the statistics:

sudo systemd-resolve --statistics