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.
Leave a Reply