How to Change the Host File on a Mac

Changing the host file on a Mac is very easy, but it’s certainly not intuitive. This little tutorial will show you how.

Launch Terminal


sudo su
vim /etc/hosts

Scroll to your desired insertion point and enter the info in this format:

IP address [space] [space]

Then the following to save and close the file:



This comes in handy when doing development on a new site — point your host file to the dev server and test the site before pushing it live.

Remember to delete the entry when you want to go back to the live site. You can also comment out the entry (if you think you may want to use it in the future) by prepending the entry with a # — example:

# IPaddress

Thanks Casey!

Bonus:  Disabling the Firefox DNS cache

One Response to “How to Change the Host File on a Mac”

  1. Mardell Proffitt Says:

    Just landed on this post via Google lookup. I love it. This post switch my perceptual experience and I am getting the RSS feeds. Cheers.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: