Page 1 of 1

How to Flush your local DNS (Mac, Windows, Linux)

How to Flush your local DNS (Mac, Windows, Linux)
   0

Flush DNS – Sometimes we do run into network issues, and sometimes this is caused by a corrupted DNS cache on your computer.

In this article a quick and easy overview on how to flush the DNS cache on your computer for several operating systems:

  • Windows (Windows 95 up to Windows 10)
  • macOS (10.6 Snow Leopard up to 11.0 Big Sur)
  • Linux (several methods)



Overview

What is a DNS cache?

A DNS cache (also called “DNS resolver cache”) is a temporary list on your computer’s operating system, that contains records of all the recent resolved DNS request. A DNS resolve request is basically asking for the correct IP address, based on a network name or address (URL). The idea behind that is that a next request to “translate” a URL (website address, server name, etc) to an IP address, will be much faster.

In other words: Each time your computer needs to look up a DNS entry, the entry is temporary stored in this list for faster retrieval with the next request for an IP address.

Looking up a DNS entry is needed so your computer can link an address (eg. www.google.com) to a matching IP address (172.217.168.196). This way your computer, and the network it is attached to (which may include the Internet), can find its way to said. This typically happens in the background in a way that the user doesn’t even know that this is happening. Resolving a DNS entry is not just for websites or email servers, but also used for device in your local network like printers, a NAS, an IP camera, your router, other PC’s etc.

Now your computer caches that, as said before, but this cache can get corrupted – even though it is relatively rare.

In such a case, your computer may not be able to reach the device or server, and this cache may need to be flushed (cleared).

Flushing the DNS is done differently for each operating system, and can even be different per version of a given Operating System.

Flush DNS Cache in Windows

For all Windows versions, flushing the DNS is done on the Command Prompt with ipconfig /flushdns.
Accessing the command prompt is per Windows version a little different (you may need for Admin rights as well).

Opening the Command Prompt in Windows

Windows 8, 8.1 and 10

Flushing the DNS under Windows 10 requires admin rights, and opening the Command Prompt is done as such:

  1. Use the Windows search option – click the “Start   button , and start typing CMD .
  2. Right-click Command Prompt and choose Run as Administrator.
  3. In the Command Prompt window, type ipconfig /flushdns  and press Enter.

Windows Vista, Windows 7

In order to flush DNS cache on Windows 7, you need to open Command Prompt as Administrator. Here’s how.

  1. Select click “Start   All Programs Accessories and select Command Prompt.
  2. Right-click Command Prompt and choose Run as Administrator.
  3. In the Command Prompt window, type ipconfig /flushdns  and press Enter.

Windows 95, 98, ME, NT, 2000, XP

For older Windows versions, the command prompt is opened as such:

  1. Click on “Start   Run  Type: cmd.exe   click OK.
  2. Type ipconfig /flushdns in the Command Prompt, and press Enter.

Flush DNS Cache in Mac OS

Flushing the DNS cache under macOS is quite possible as well.
Check your macOS version by clicking the Apple menu ( ) About this Mac.

We need to execute this in Terminal (you can find Terminal in your Applications: Applications  Utilities Terminal))

macOS 10.7 Lion – 11.0 Big Sur (NOT 10.10 Yosemite)

To flush DNS on MacOS 10.7 and higher (tested up to 10.15), follow these steps – you will need an admin account (sudo-access).

Caution: macOS 10.10 Yosemite is an exception in this list, see the next paragraph on how to do a DNS Flush for Yosemite.

  1. Open Terminal (Application  Utilities Terminal)
  2. Now in Terminal type sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder  and press Enter.
  3. Enter your password if asked for (characters you type may not appear on the screen) and press Enter.
  4. You can now close the Terminal.

Mac OS X 10.10 Yosemite

In order to flush DNS on MacOS X Yosemite, things get a little odd, especially when you see how it is done in older and newer macOS versions- you will need an admin account (sudo-access)..

  1. Open Terminal (Application  Utilities Terminal)
  2. In Terminal type sudo discoveryutil mdnsflushcache; sudo discoveryutil udnsflushcaches  and press Enter.
  3. Enter your password if asked for (characters you type may not appear on the screen) and press Enter.
  4. You can now close the Terminal.

Mac OS X 10.5 Leopard and 10.6 Snow Leopard

In these macOS versions we flush DNS like so:

  1. Open Terminal (Application  Utilities Terminal)
  2. Type dscacheutil -flushcache in Terminal and press Enter to run the command
  3. You can now close the Terminal.

Mac OS X 10.4 Tiger and older …

For macOS 10.4 and older:

  1. Open Terminal (Application  Utilities Terminal)
  2. In Terminal type lookupd -flushcache  and press Enter .
  3. You can now close the Terminal.

Flush DNS Cache in Linux

In Linux, just as seen under Windows and macOS, we will need to execute a command in Terminal as well.

The average Linux user will be very familiar with how to open a Terminal window.
Most will know where to find the shortcut, and with most the following key combination may do the trick as well: Ctrl + Alt + T.

However, due to the sheer amount of Linux variations, your setup may be different. It all depends on what is being used for the DNS caching.
A few commonly used methods are listed below.

Note: all these Flush DNS methods require an admin account (sudo access)!

nscd DNS Cache

Open Terminal and type sudo /etc/init.d/nscd restart and press Enter to execute.

dnsmasq DNS

Open Terminal and type sudo /etc/init.d/dnsmasq restart and press Enter to execute.

BIND DNS Cache

Open Terminal and execute one of these command, and press Enter to execute:

Option 1: sudo /etc/init.d/named restart

Option 2: sudo rndc restart

Option 3: sudo rndc exec

Ubuntu

Ubuntu is one of the most commonly used Linux distro for desktop use, so here a little more detail for this specific distro.
Note: I’m not an Ubuntu expert, but just thought I’d mention these few that I ran into.

Ubuntu 17.x and newer

Open Terminal and type sudo systemd-resolve --flush-caches and press Enter to execute.

Ubuntu when utilizing dnsmasq (12.x?)

Open Terminal and type sudo service network-manager restart and press Enter to execute.

Ubuntu versions before 17.x

There appears to be no DNS caching, unless you installed something specifically for that. So there is nothing to flush (source).

General thing to try in Ubuntu

In case you’re not quite sure about your Ubuntu setup, then you could try the following:
Open Terminal and type sudo /etc/init.d/networking force-reload  and press Enter to execute.

Support Us ...


Your support is very much appreciated, and can be as easy as sharing a link to my website with others, or on social media.

Support can also be done by sponsoring me, and even that can be free (e.g. shop at Amazon).
Any funds received from your support will be used for web-hosting expenses, project hardware and software, coffee, etc.

Thank you very much for those that have shown support already!
It's truly amazing to see that folks like my articles and small applications.

Please note that clicking affiliate links, like the ones from Amazon, may result in a small commission for us - which we highly appreciate as well.

Comments


There are no comments yet.
You can post your own comments by using the form below, or reply to existing comments by using the "Reply" button.



Your Comment …

Do not post large files here (like source codes, log files or config files). Please use the Forum for that purpose.

Please share:
*
*
Notify me about new comments (email).
       You can also use your RSS reader to track comments.


Tweaking4All uses the free Gravatar service for Avatar display.