Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

How to Clear the Local DNS Cache in Linux

If a website still loads from an old server after a change, your computer may remember the old address. This guide shows how to make it forget.

Web Hosting2 min read7 steps

What is the DNS cache?

DNS is the phone book of the internet. It turns a site name, like example.com, into a number called an IP address. A cache is a short-term memory. Your computer saves each answer so it does not have to ask again. This is fast. But after you move a site, the saved answer can be old. Clearing the cache makes your computer ask again.

Before you start

Open a terminal. The terminal is the window where you type commands. You need admin rights, so most commands start with sudo. Sudo means "run as the boss user".

Linux has several ways to do DNS. The right command depends on what your system uses. Try the ones below until one works.

Steps

  1. Check if you use systemd-resolved:
    systemctl is-active systemd-resolved
    If it prints active, use step 2.
  2. Clear the cache:
    sudo resolvectl flush-caches
    On older systems use this instead:
    sudo systemd-resolve --flush-caches
  3. Check that it worked:
    resolvectl statistics
    The cache size should show 0 entries.

Other DNS programs

  • nscd: run sudo systemctl restart nscd.
  • dnsmasq: run sudo systemctl restart dnsmasq.
  • BIND (named): run sudo rndc flush.

Each command either empties the saved answers or restarts the program that holds them.

If it does not help

  1. Clear your browser cache. Browsers keep their own saved addresses.
  2. Close and reopen the browser.
  3. Wait. Changes to DNS can take a few hours to spread across the internet.
  4. Ask Hostvento support if the site still points to the wrong place.
Tip: Run nslookup yourdomain.com to see which IP address your computer gets. Use your own domain name.

Quick recap

  • DNS cache is your computer's memory of site addresses.
  • Old memory can show an old site.
  • Most systems use sudo resolvectl flush-caches.
  • Other programs need a restart.
  • Clear your browser cache too.