Useful macOS network terminal commands | flush the DNS cache


In this video, we’ll show you a handy macOS Big Sur terminal command that can help you fix a common issue with your computer’s DNS (Domain Name System). If you’re frequently seeing 404 errors or web pages not loading, it might be because your DNS is acting up. But don’t worry, this command can help you flush and reset your DNS, and get your internet back up and running in no time!

Just a heads up, while Terminal commands are commonly used by IT folks, if you’re not a pro at typing them, don’t worry! On an Apple Mac, simply rebooting the computer will automatically clear its DNS Cache.

Note: DNS (Domain Name System) is like a digital Yellow Pages, but instead of matching names and addresses to phone numbers, it helps us convert IP addresses to domain names and vice versa.

However in order to speed up page loading when browsing the internet. After visiting a website, that sites address is stored locally on your computer in something called a “Cache“. This cache is then referred to when you try and revisit the same page, which makes loading that page faster.

  • Open the Terminal application. found in the Utilities folder within Applications
  • Type the following:

Note: You will not be able to run this command if the account you are working from does not have administrative rights over your computer. If this is the case then you will need to use the su command to give your terminal session administrative rights. 

su [admin username]
  • When you press enter on the keyboard you will be prompted for a password. Enter you administrators password.
  • Now enter the following command syntax exactly (use copy and paste if in doubt about syntax accuracy):
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder; say DNS cache has been flushed
  • Hit the Enter key
  • Once again you will be prompted to enter the administrators password
  • Your computer will inform you that your DNS cache has been flushed.
  • You can now close the Terminal panel.

2 comments

Leave a Reply to Editorial Team Cancel reply

Your email address will not be published. Required fields are marked *

Our site members

Thank you

Support This Site

If you enjoy our content but don't want to be a site member. Please consider supporting us on Ko-fi to keep us ads free. Thanks for all your support