How to edit hosts file on Mac OS X (Snow Leopard)?

If you want to bind an ip address to a host name or block a certain applications from connecting to a specific server address, you can add that information to the hosts file. Here is how you do it.

  1. Log in as an admin. user.
  2. Open the Terminal.app located at Applications > Utilities > Terminal.app.
  3. Use
    sudo nano /private/etc/hosts

    to open the hosts file

  4. Add the corresponding record.
    Eg.: 127.0.0.1 activate.adobe.com
  5. Press Control+o to save and Control+x to exit the nano editor.
  6. Use
    dscacheutil -flushcache

    to clear DNS cache.

That’s all. Have fun!

Be Sociable, Share!
Categories: Tips & Tricks, Unix
  • http://www.australianglazing.com.au Melbourne Commercial Glass

    Thanks for the posts. This will be helpful and a great tool for any website designer. Looking forward to check more on this in the future.