Skip to main content
Blue Apple

Clearing the DNS cache on a Mac or MacBook (flush DNS)

Websites will not load or show an old version? How to flush your Mac's DNS cache with one Terminal command, and how to set other DNS servers.

Clearing the DNS cache on a Mac or MacBook (flush DNS)

Clearing the DNS cache on a Mac ("flush DNS") helps when websites will not load, you see an old version of a site, or a site no longer works after moving to a new server. On a Mac you do it with one command in Terminal. This article explains what DNS is, when flushing makes sense and how to do it.

Blue Apple repairs MacBooks in Amsterdam. If the internet does not work on your MacBook at all, while it works on your phone, Wi-Fi or the hardware may be the cause; more about that at the end.

What is DNS?

DNS is the phone book of the internet: it translates a name like blueapple.nl into the address of the server. Your Mac remembers those translations for a while in a cache, so sites load faster. If a site's address changes, or the cache gets confused, your Mac may use a wrong or old address.

When does flushing make sense?

  • One or a few sites do not load, while they work on other devices.
  • You see an old version of a website that was just changed or moved.
  • You changed your DNS settings or your router.
  • You get errors like "server not found".

How to flush the DNS cache

  1. Open Terminal (via Spotlight: Command + Space bar, type "terminal").
  2. Type this command and press Return:
    sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
  3. Enter your password. You see no characters while typing; that is normal. Press Return.
  4. You get no confirmation, but the cache is empty. Reload the website.

If it does not work straight away, also quit your browser completely (Command + Q) and open it again. Browsers sometimes have their own cache.

Your browser's cache

Besides the macOS DNS cache, browsers keep their own copies of pages. If you still see an old version after flushing, reload the page without cache: in Safari with Option + Command + R, in Chrome and Firefox with Shift + Command + R. In Chrome you can also clear the browser's own DNS cache via chrome://net-internals/#dns.

Setting other DNS servers

By default your Mac uses your internet provider's DNS servers. If they work poorly, you can set others:

  1. Open System Settings, Network, and click Wi-Fi.
  2. Click Details next to your network and choose DNS.
  3. Use the plus button to add the addresses of the DNS service you want to use, and click OK.

Remember what was there before you change anything, so you can put it back. On a work or school network you had better not change anything.

It does not help: other causes

  • Does it fail on every device? Then it is your router, your provider or the website itself. Restart the router.
  • Only your Mac fails? Turn Wi-Fi off and on, forget the network and reconnect, and check whether a VPN or security program blocks the connection.
  • Wi-Fi keeps dropping or your MacBook no longer finds networks: there may be something with the Wi-Fi hardware or antenna, for example after liquid or a drop.

What we do at Blue Apple in Amsterdam

We test whether your MacBook's Wi-Fi and Bluetooth hardware works properly and find out whether a problem is in the software, the antenna or the logic board. You hear beforehand what is going on. More on our page about MacBook repair in Amsterdam. Also read Activity Monitor explained to see what uses your network.

Frequently asked questions

Is flushing the DNS cache safe?

Yes. Your Mac rebuilds the cache by itself. You lose nothing.

Do I have to restart the Mac after flushing?

No, it works straight away. Restarting also clears the cache.

Does the same command work on older macOS versions?

For all recent versions, yes. On very old versions the command was slightly different.

Book a repair