For the longest time, I used the Hostbuddy for Mac app to edit my hosts file and flush my local DNS cache. I still recommend the app to anyone who wants to edit their hosts file on Apple’s operating system using a GUI. However, I have recently started using the command line in conjunction with VS Code.

To edit the hosts file on macOS I added the following commands to my .zshrc file:

alias hostsedit='sudo code /etc/hosts'
alias hostsflush='sudo killall -HUP mDNSResponder; echo DNS Cache Reset'

These two commands let me edit and flush my hosts file’s modifications to my local machines DNS without much effort.


Comments

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Get Involved & Explore More

an abstract painting with blue and yellow colors

Catch up on what I’ve been writing lately.

Show your gratitude.

Join Dare To Code Email List

Get emails from me on full-stack PHP development by subscribing to the Dare To Code mailing list.