User Agents

Web browsers and everyday web tech, explained

Clear DNS Cache on Mac: Step-by-Step Guide for macOS

· 5 min read · Cookies and Cache

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Clearing the DNS cache on a Mac, also known as flushing DNS, removes the local database of IP addresses that your computer stores to speed up website loading. This process is essential when a website has moved to a new server or changed its IP address, but your computer continues to try and connect to the old, outdated location, resulting in "Page Not Found" or connection timeout errors. By flushing the cache, you force macOS to request a fresh, updated DNS record from the server, resolving connectivity issues and ensuring you are reaching the correct destination.

What You'll Need

  • A Mac computer running macOS.
  • Administrative privileges (you will need your user password to authorize the command).
  • An active internet connection to test the results.

Step-by-Step

  1. Open the Terminal application: The DNS cache cannot be cleared through the standard System Settings menu; it requires a command-line interface. You can find Terminal by opening Finder, navigating to Applications, then opening the Utilities folder. Alternatively, press Command + Space to open Spotlight search, type "Terminal," and press Enter.
  2. Identify your macOS version: Because the command to flush DNS has changed slightly across different versions of macOS, you need to know which version you are running. Click the Apple menu () in the top-left corner of your screen and select About This Mac. Note the version name (e.g., macOS Sonoma, Ventura, Monterey, Big Sur, or Catalina).
  3. Enter the flush command: Depending on your version, copy and paste the corresponding command into the Terminal window. For most modern versions (macOS Big Sur, Monterey, Ventura, and Sonoma), use the following command:
    sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
    If you are on an older version like macOS High Sierra or Mojave, the command may vary slightly, but the mDNSResponder command remains the primary method for clearing the cache.
  4. Execute the command: After pasting the command, press the Return key.
  5. Provide your administrator password: Because the command starts with sudo (superuser do), macOS requires administrative authorization. Terminal will prompt you for your password. Type your Mac login password and press Return. Note that for security reasons, the cursor will not move and no characters (like asterisks) will appear as you type; this is normal behavior.
  6. Verify completion: Once the command is executed, Terminal will simply return you to a new blank command prompt line. There is typically no "Success" message, but the lack of an error message indicates the process was completed.
  7. Restart your browser: To ensure the changes take effect, completely quit your web browser (Cmd + Q) and relaunch it. This clears any browser-level DNS caching that may still be active.

Common Mistakes

  • Typing the password incorrectly: Since the Terminal does not show characters while typing the password, many users think the keyboard is not working or they have made a mistake. Type carefully and press Enter.
  • Using the wrong command for the OS version: While the mDNSResponder command is widely compatible, using a command meant for Windows or Linux will result in a "command not found" error.
  • Forgetting to restart the browser: Some browsers, particularly Google Chrome, maintain their own internal DNS cache separate from the operating system. If the site still won't load, the browser itself may need a restart or a specific internal flush.
  • Mistyping the syntax: A single missing semicolon or space in the command string will cause the command to fail. Copying and pasting the command is the safest method.

Tips

  • Combine with a Browser Reset: If you are clearing DNS to fix a specific website issue, try clearing your browser's temporary files and cookies at the same time for a completely clean slate.
  • Check your DNS Server: If flushing the cache doesn't work, the issue might be with your ISP's DNS servers. Consider switching to a public DNS provider like Google (8.8.8.8) or Cloudflare (1.1.1.1) in your Network settings.
  • Use a Text Editor: If you frequently need to run Terminal commands, keep a simple text file with the correct commands for your specific macOS version so you can copy and paste them quickly.

Troubleshooting

If you have followed the steps but the website still does not load, consider the following solutions:

  • "Command Not Found" Error: This usually means there was a typo in the command. Ensure there is a space after sudo and that the spelling of mDNSResponder is exact (it is case-sensitive).
  • "Permission Denied" Error: This occurs if the account you are logged into does not have administrator privileges. You must be logged into an admin account to use the sudo command.
  • Site still unreachable: If the DNS flush didn't work, the problem may be at the server level (the website is actually down) or a local network issue. Try accessing the site from a different device on the same network to determine if the problem is specific to your Mac.
  • Network Reset: If all else fails, try toggling your Wi-Fi off and back on, or restarting your router to clear the DNS cache stored on your hardware.

Frequently Asked Questions

Will clearing my DNS cache delete my bookmarks or passwords?

No. Flushing the DNS cache only removes the temporary map of domain names to IP addresses. It does not affect your browser history, saved passwords, bookmarks, or any personal files.

How often should I clear my DNS cache?

There is no need to do this on a schedule. You should only clear your DNS cache when you encounter specific connectivity issues or when you know a website has changed its hosting server.

Is it safe to use the Terminal for this?

Yes, as long as you use the specific commands provided. The dscacheutil and killall commands are standard macOS utilities designed for system maintenance.

Why does my Mac have a DNS cache in the first place?

The cache exists to improve performance. By storing the IP address of a site you visit frequently, your Mac doesn't have to ask a DNS server for the address every single time, which makes pages load faster.

Does flushing DNS fix slow internet speeds?

Generally, no. DNS flushing fixes "cannot find server" or "wrong page" errors. It does not increase your overall bandwidth or internet connection speed.