How to clear the DNS cache on Windows, Mac and Linux

Published Updated

To clear the DNS cache, run ipconfig /flushdns on Windows or sudo killall -HUP mDNSResponder on a Mac. Restarting your router also clears its cache.

Your computer, your router and your browser each keep a DNS cache, a short-term copy of which server each domain points to. After you move a website or point your domain to 2MHost, this cache can keep showing you the old server. Clearing it makes your computer look up the domain again.

Clear the DNS cache by restarting your router

This method needs no commands and clears the cache in your router and your browser.

  1. Close all open browser windows.
  2. Turn off your internet router or modem.
  3. Wait 5 minutes.
  4. Turn the router back on and wait until the internet connection works again.
  5. Open your browser and load the website.

If the website still shows the old version, clear the cache on your computer with one of the methods below.

Clear the DNS cache on Windows

On Windows 11, Windows 10 and earlier versions, you clear the DNS cache from the Command Prompt.

  1. Press Windows + R to open the Run box.
  2. Type cmd and press Enter. The Command Prompt opens.
  3. Type the following command and press Enter:
ipconfig /flushdns

Windows shows the message Successfully flushed the DNS Resolver Cache.

Clear the DNS cache on macOS

On a Mac, you clear the DNS cache in the Terminal app.

  1. Open Finder › Applications › Utilities › Terminal.
  2. Type the following command and press Return:
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
  1. Enter your Mac login password when Terminal asks for it, then press Return. The password does not appear on screen while you type.

The command shows no message when it works. Terminal returns to the prompt, ready for the next command.

Note: Very old Mac OS X versions use different commands. On Mac OS X 10.5 Leopard, run dscacheutil -flushcache. On Mac OS X 10.5.1 and earlier, run lookupd -flushcache.

Clear the DNS cache on Linux

On Linux, the command depends on which service caches DNS on your system. Run these commands in a terminal.

Most current distributions, including Ubuntu and Fedora, use systemd-resolved. To clear its cache, run:

sudo resolvectl flush-caches

If your system uses nscd, the name service cache daemon, restart it instead:

sudo systemctl restart nscd

On older systems without systemctl, restart nscd with its init script:

sudo /etc/rc.d/init.d/nscd restart

If none of these services is installed, your Linux system does not cache DNS itself. Restart your router and browser instead.

Clear the DNS cache in Google Chrome

Google Chrome keeps its own DNS cache, separate from your computer's.

  1. In Chrome, type chrome://net-internals/#dns in the address bar and press Enter.
  2. Click Clear host cache.
  3. Close all Chrome windows and open Chrome again.

If the page still looks old, the problem may be stored files rather than DNS. See How to clear the browser cache in Google Chrome.

Frequently asked questions

Is it safe to clear the DNS cache?

Yes. It deletes no files, passwords or browsing history. Your computer rebuilds the cache as you visit websites.

Does clearing my DNS cache make DNS changes work faster for everyone?

No. It only affects your own device. Visitors see the change when their own DNS cache and their provider's cache expire.

Related articles