{"id":376,"date":"2025-05-08T14:14:39","date_gmt":"2025-05-08T13:14:39","guid":{"rendered":"https:\/\/www.speedhub.eu\/blog\/?p=376"},"modified":"2025-05-08T14:14:39","modified_gmt":"2025-05-08T13:14:39","slug":"how-to-delete-dns-cache-on-linux","status":"publish","type":"post","link":"https:\/\/www.speedhub.eu\/blog\/2025\/05\/08\/how-to-delete-dns-cache-on-linux\/","title":{"rendered":"How to delete DNS cache on Linux?"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"457\" src=\"https:\/\/www.speedhub.eu\/blog\/wp-content\/uploads\/2025\/05\/dns-1024x457.png\" alt=\"dns linux\" class=\"wp-image-378\" srcset=\"https:\/\/www.speedhub.eu\/blog\/wp-content\/uploads\/2025\/05\/dns-1024x457.png 1024w, https:\/\/www.speedhub.eu\/blog\/wp-content\/uploads\/2025\/05\/dns-300x135.png 300w, https:\/\/www.speedhub.eu\/blog\/wp-content\/uploads\/2025\/05\/dns-768x343.png 768w, https:\/\/www.speedhub.eu\/blog\/wp-content\/uploads\/2025\/05\/dns-1536x686.png 1536w, https:\/\/www.speedhub.eu\/blog\/wp-content\/uploads\/2025\/05\/dns-2048x914.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">To delete the DNS cache on most used Linux distributions, the commands will vary depending on the distribution and version:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"ubuntu1404trustytahr\">Ubuntu 14.04 (Trusty Tahr)<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Ubuntu 14.04 uses <code>dnsmasq<\/code> as the DNS resolver. To clear the DNS cache, you can restart the <code>dnsmasq<\/code> service:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo service dnsmasq restart\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"ubuntu1604xenialxerus\">Ubuntu 16.04 (Xenial Xerus)<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Ubuntu 16.04 uses <code>systemd-resolved<\/code> as the DNS resolver. To clear the DNS cache, you can restart the <code>systemd-resolved<\/code> service:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl restart systemd-resolved\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"ubuntu1804bionicbeaver\">Ubuntu 18.04 (Bionic Beaver)<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Ubuntu 18.04 also uses <code>systemd-resolved<\/code>. The command to clear the DNS cache remains the same:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl restart systemd-resolved\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"ubuntu2004focalfossaandlater\">Ubuntu 20.04 (Focal Fossa) and Later<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Ubuntu 20.04 and later versions continue to use <code>systemd-resolved<\/code>. To clear the DNS cache, you can use the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl restart systemd-resolved\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"almalinux7\">AlmaLinux 7<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">AlmaLinux 7 uses <code>nscd<\/code> (Name Service Cache Daemon) for DNS caching. To clear the DNS cache, you can restart the <code>nscd<\/code> service:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl restart nscd\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If you are using <code>dnsmasq<\/code> for DNS caching, you can restart the <code>dnsmasq<\/code> service:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl restart dnsmasq\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"almalinux8\">AlmaLinux 8<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">AlmaLinux 8 uses <code>systemd-resolved<\/code> for DNS caching. To clear the DNS cache, you can restart the <code>systemd-resolved<\/code> service:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl restart systemd-resolved\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If you are using <code>nscd<\/code> for DNS caching, you can restart the <code>nscd<\/code> service:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl restart nscd\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"almalinux9\">AlmaLinux 9<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">AlmaLinux 9 continues to use <code>systemd-resolved<\/code> for DNS caching. The command to clear the DNS cache remains the same:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl restart systemd-resolved\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"debian7wheezy\">Debian 7 (Wheezy)<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Debian 7 uses <code>nscd<\/code> (Name Service Cache Daemon) for DNS caching. To clear the DNS cache, you can restart the <code>nscd<\/code> service:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo service nscd restart\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"debian8jessie\">Debian 8 (Jessie)<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Debian 8 also uses <code>nscd<\/code> for DNS caching. The command to clear the DNS cache remains the same:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo service nscd restart\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"debian9stretch\">Debian 9 (Stretch)<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Debian 9 uses <code>systemd-resolved<\/code> for DNS caching. To clear the DNS cache, you can restart the <code>systemd-resolved<\/code> service:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl restart systemd-resolved\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If you are using <code>nscd<\/code> for DNS caching, you can restart the <code>nscd<\/code> service:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl restart nscd\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"debian10buster\">Debian 10 (Buster)<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Debian 10 continues to use <code>systemd-resolved<\/code> for DNS caching. The command to clear the DNS cache remains the same:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl restart systemd-resolved\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If you are using <code>nscd<\/code> for DNS caching, you can restart the <code>nscd<\/code> service:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl restart nscd\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"debian11bullseyeandlater\">Debian 11 (Bullseye) and Later<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Debian 11 and later versions continue to use <code>systemd-resolved<\/code>. To clear the DNS cache, you can use the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl restart systemd-resolved\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If you are using <code>nscd<\/code> for DNS caching, you can restart the <code>nscd<\/code> service:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl restart nscd\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"additionalstepsforallversions\">Rocky Linux 7<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Rocky Linux 7 uses <code>nscd<\/code> (Name Service Cache Daemon) for DNS caching. To clear the DNS cache, you can restart the <code>nscd<\/code> service:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl restart nscd\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If you are using <code>dnsmasq<\/code> for DNS caching, you can restart the <code>dnsmasq<\/code> service:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl restart dnsmasq\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"rockylinux8\">Rocky Linux 8<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Rocky Linux 8 uses <code>systemd-resolved<\/code> for DNS caching. To clear the DNS cache, you can restart the <code>systemd-resolved<\/code> service:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl restart systemd-resolved\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If you are using <code>nscd<\/code> for DNS caching, you can restart the <code>nscd<\/code> service:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl restart nscd\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"rockylinux9\">Rocky Linux 9<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Rocky Linux 9 continues to use <code>systemd-resolved<\/code> for DNS caching. The command to clear the DNS cache remains the same:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl restart systemd-resolved\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If you are using <code>nscd<\/code> for DNS caching, you can restart the <code>nscd<\/code> service:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl restart nscd\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"additionalstepsforallversions\"><\/h3>\n","protected":false},"excerpt":{"rendered":"<p>To delete the DNS cache on most used Linux distributions, the commands will vary depending on the distribution and version: Ubuntu 14.04 (Trusty Tahr) Ubuntu 14.04 uses dnsmasq as the DNS resolver. To clear the DNS cache, you can restart&hellip; <a href=\"https:\/\/www.speedhub.eu\/blog\/2025\/05\/08\/how-to-delete-dns-cache-on-linux\/\" class=\"more-link\">Continue Reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":378,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[97,67,30,92,23],"class_list":["post-376","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-vps-servers","tag-almalinux","tag-debian","tag-linux","tag-rocky-linux","tag-ubuntu"],"_links":{"self":[{"href":"https:\/\/www.speedhub.eu\/blog\/wp-json\/wp\/v2\/posts\/376","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.speedhub.eu\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.speedhub.eu\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.speedhub.eu\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.speedhub.eu\/blog\/wp-json\/wp\/v2\/comments?post=376"}],"version-history":[{"count":2,"href":"https:\/\/www.speedhub.eu\/blog\/wp-json\/wp\/v2\/posts\/376\/revisions"}],"predecessor-version":[{"id":379,"href":"https:\/\/www.speedhub.eu\/blog\/wp-json\/wp\/v2\/posts\/376\/revisions\/379"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.speedhub.eu\/blog\/wp-json\/wp\/v2\/media\/378"}],"wp:attachment":[{"href":"https:\/\/www.speedhub.eu\/blog\/wp-json\/wp\/v2\/media?parent=376"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.speedhub.eu\/blog\/wp-json\/wp\/v2\/categories?post=376"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.speedhub.eu\/blog\/wp-json\/wp\/v2\/tags?post=376"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}