Pretty often, I have a need for editing my hosts file on my Mac. Mostly when i’m moving websites between webservers. This is not a problem on a windows machine, but on a Mac, you need to make a few more steps.

To editing the hosts file you need to do the following:

  1. Start Terminal.app (click on search and type terminal)
  2. Open the hosts file ($ sudo nano /private/etc/hosts) type your Password when promted
  3. Edit the content of the hosts file to suit your purpose
  4. Save the file by pressing “ctrl+o”
  5. Exit the editingprogram by pressing “ctrl+x”
  6. Reset the DNS-cache ($ dscacheutil -flushcache)
  7. Close terminal.app by typing “exit”


Leave a Reply

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