October 27, 2009

How to Edit the Hosts File Mac OS X Snow Leopard

<div class=\"postavatar\">how-to-edit-the-hosts-file-mac-os-x-snow-leopard</div>

Do you need a free shell account?
Then sign up at Devio.us!
You’ll get unrestricted shell access via SSH and access to all standard software – compilers, IRC clients, mail clients, screen, etc. Check out the details at http://devio.us/services

There are times during DNS changes or other testing that you may want to specify a particular IP for a domain name. To do this, you’ll need to edit your hosts file. This way you can “trick” your computer before DNS actually changes or point a domain to another IP, even a local one. Some of the instructions out there on how to do this are a little too bloated, so I tried to simplify them as much as possible here on DotResults. If you have any questions about this, please leave a comment and we’ll get back to you as soon as we read it.


1. Open Terminal

2. Paste this command:
sudo nano /private/etc/hosts
You’ll be asked to enter your administrator password.

3. Arrow down to the last line, highlighted here, and type your entry like this: 137.61.27.216 www.tech.com

4. Press control+x. Type the letter Y. This saves the file.

5. To flush your DNS cache so the changes take effect, paste this command next:
dscacheutil -flushcache

6. You can test if it has worked by using the PING command. Try PING tech.com and PING www.tech.com – the IP addresses should be different.


Share

Read more from OS X
About the author, Kayla

First a geek, now a photographer too. Check out my site at kaylaselans.com

9 Comments Post a comment
  1. Lauren
    Oct 25 2010

    Thanks a lot! Really helped me out :)

  2. Glen
    Mar 29 2011

    Where do I paste the command to flush?

  3. Glen
    Mar 29 2011

    OK sorted it!

  4. Glen
    Mar 29 2011

    Thank you by the way!

  5. Ilhan
    Jun 29 2011

    Thank you this helped me a lot! I couldn’t find a decent explanation until I came upon your page. Cheers.

  6. Richard Tibbitts
    Sep 11 2011

    This is the first time I’ve ever experienced success at editing the hosts file, after several years of intermittent attempts. Nobody shows you how to use the command line; they just say “Uh, edit the hosts file,” or “Go to private/etc/hosts,” or something like that.

    So thank you for being concise and accurate!

  7. Oct 10 2011

    This was great! The only hiccup I experienced was in saving the hosts file. After you hit Cntrl+x and then type the letter y, you then have to hit enter!

    Thanks for the instructions.

  8. William
    Oct 26 2011

    Great article. Easy to understand. Thanks for the help!

Trackbacks & Pingbacks

  1. Tweets that mention How to Edit the Hosts File Mac OS X Snow Leopard -- Topsy.com

Leave a Comment

Note: Make sure you enter the required information where indicated. HTML is allowed. Your email address is Required but, will never be published.

Required
Required, but not shared

Get notified Subscribe to comments