Guide to Hosts File For Mac OS X Lion Users

This article guides you through the hosts file, its uses, and how to edit hosts file either manually or with the help of free apps on your Mac computer.

What is a Hosts File?

Hosts file is a plain-text file residing on your Mac system. Consider hosts file as an address book which is under the control of admin and can be used to map host names to IP addresses.

For example, if you want to redirect to on your local machine, use hosts file. If you want to block a website or exclude advertisement on the Internet, use hosts file.

And if you want to exclude a particular Internet application from executing on your browser, use hosts file. You get the point — you can configure hosts file to redirect, resolve IP, block and exclude content.

Benefits of Hosts File

Configuring your Mac’s hosts file can be helpful in many ways such as:

  • You can block the IP calls on any port without having to buy blocking software for your Mac.
  • Hosts file can resolve IP addresses which can cut the time required to find a website.
  • If a website is found suspicious, you can exclude it from the hosts file.
  • As a parent, you can use hosts file to block Facebook, iTunes, or anything that you think is inappropriate for your kid.
  • You can use hosts file to disable ads on the Internet.


Hosts File Location On Mac OS X Lion

Mac OS X Lion users can access the host file by navigating to /etc/hosts. You can manually edit the host file by opening the file in TextEdit. If the file is locked, you can always use Terminal to edit hosts file.

You might also like:  Updating Java on Mac OS

This is how the default host file on Mac OS X 10.7 Lion looks like:

# Host Database
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##    localhost    broadcasthost
::1             localhost
fe80::1%lo0    localhost

You can add entries to the host file. For example, if you want to block Facebook, Twitter and Apple server from your local machine, then you’ve to add these lines to the original hosts file:

So, whenever any one of these website is accessed from your Mac’s browser, the host file is checked and appropriate action is taken — all the three sites are blocked, in this case.

Related: Several ways to block websites on Mac.

Edit Hosts File on Mac Computer

Like Windows users, Mac users can block sites and do a lot more by editing hosts file either manually or with the help of free apps.

Whether you are using MacBook Pro, MacBook Air, or an iMac, editing hosts file follows the same procedure. And if you are in a rush, or you are not familiar with Terminal and commands, then it’s always recommended to use apps to edit the hosts file.

For those who want to manually edit hosts file through Terminal, fire up Terminal and type sudo nano /etc/hosts and the rest of the process should be fairly easy to follow.

Learn more on how to edit hosts file manually.

Gas Mask is a nifty little tool that hands you the control over the hosts file of your Mac. Gas Mask flaunts a Mac-friendly interface where you can easily edit hosts file.

You might also like:  Get Back Older iChat Logs and Messages

You can also add remote hosts file which will be updated automatically as you edit and update the hosts file. With Gas Mask, you no longer have to worry about typing wrong commands in the Terminal. You can create and switch between multiple hosts file and use shortcuts for editing hosts file.

Download Gas Mask (Works on Mac OS X 10.7 Lion and Snow Leopard).

Another solution to modify hosts file is to download Hosts Widget, which is a dashboard widget. The widget lets you create entries, disable older entries, and automatically flushes DNS cache right from your Mac’s Dashboard.

Another Mac-friendly hosts file editor is Host Manager. Once you have the admin password locked in, adding and removing entries is a piece of cake with this app.