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

Type:

sudo su
vim /etc/hosts
shift-a

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

IP address [space] http://www.example.com [space] example.com

Then the following to save and close the file:

esc
:wq
enter
exit

Done!

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 http://www.example.com example.com

Thanks Casey!

Bonus:  Disabling the Firefox DNS cache

Advertisements

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:

WordPress.com Logo

You are commenting using your WordPress.com 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: