Hosts is a system preference pane to manage your hosts file.
Hosts add a preference pane to your system preferences which lets you toggle your host file entries on and off, as well as add and remove them.
Hosts.prefpane likes to keep your hosts file clean. When an entry is toggled off, it is not commented out in the hosts file, but instead stored in the app's preferences storage. This means you will have to uncomment all your unused host entries and untoggle them in the prefpane if you want to use them. Comments are treated as comments and will never show up in the list
For those Mac users who feel uncomfortable dabbling in the Terminal using the Terminal app, this prefspane is another good example of a developer's desire to make the Mac OS interface even more user friendly than it already is.
It is little apps like these which make the Mac even more enjoyable to use, as they convey the spirit and vision of Steve Jobs himself. Our Mac computers shouldn't be viewed as challenges to use. Their underlying complex technology shouldn't scare us off. Apps like this one make sure that it doesn't.
On the other hand, if you do prefer to use the Terminal, following are the steps that you can use to edit your hosts file:
1. Open the Terminal application and paste in the following:
Great tutorial, WordWeaver! Unfortunately, I wouldn’t know what to do with the Hosts file once I’d gotten it open. I’ve heard a lot about blocking specific domains with it — could you tell me how to do that once I get to Step 4 of your tutorial? As far as I can tell — and quite surprisingly — the only extant app which does so is called Hostal, but it didn’t work for me in Lion.
Future thanks if you have time to instruct me further, and if you don’t, thanks for the tutorial you’ve already given us!
Hello GeoProf. Once you have your hosts file open, using it to block particular domains is rather easy.
When you open the hosts file, at the very least, you will find an entry which says the following:
127.0.0.1 localhost
Whatever you do, do NOT remove that entry, as it is a loopback which your OS requires.
Basically, when you block a domain, what you are actually doing is creating a loopback so that the HTTP request, or whatever kind of request it is, never even leaves your machine; rather, the request is looped back to your machine, and never goes anywhere. That is what the 127.0.0.1 IP address does. That represents your machine.
So, if you want to block certain domains, you would simply add new entries to THE BOTTOM of your hosts file, AFTER everything else that may already be in there.
You would place one entry on each line, hit your return key, and then add another one.
As you can see, you simply type "127.0.0.1", followed by a space, followed by the domain that you wish to block.
I believe that it may also be okay to use a tab instead of a space after the 127.0.0.1
Once you have added all of your entries, simply save the file and close it.
Of course, you may want to make a backup copy somewhere else on your hard drive, or on some other medium.
Note: I am not sure why, but when I just tried to follow my own instructions in the Terminal, I kept getting an error message. I don't know if it is because I am using Lion now, or if it is due to some other reason.
If you do encounter any error opening the "hosts" file, assuming that you have admin privileges on your computer, you can always open it manually as well.
To do this, you will need to make invisible System files and folders visible first. You will find a number of apps here on MacUpdate which will do this for you, such as MacPilot, iShow Invisible, TotalFinder, and a zillion others.
Once you have made your System files and folders visible, at the top level of your startup volume, look for the "etc" folder. It will probably be an alias, and will have a little curved arrow in the bottom left corner of it. Depending on what version of the Mac OS you are using, the folder may also possibly be dimmed, which indicates that it is invisible, I believe.
Once you open the "etc" folder, you will find the "hosts" file inside; rather, you will find an alias of the hosts file. The REAL hosts file is in private/etc/hosts.
If you prefer to open the hosts file with a particular text editor -- I use BBEdit -- then right click the hosts file and select the "open with" option.
At this point, depending on the ownership and permissions on the hosts file, you may possibly be requested to authenticate by providing your admin password.
Once the hosts file is open, simply follow my steps above for adding the domains that you wish to block.
I do want to mention one other thing.
Using the hosts file to block domains is a permanent thing. Once you add a domain in there, that domain will be permanently blocked until you remove it from the hosts file.
For example, if you add www.apple.com to your hosts file, you can forget about trying to go to any of Apple's websites. :)
There are times when you do not always want to block an IP or domain name permanently. There are also times when you may also want to only block certain ports that a domain uses. And there are many other possibilities as well, depending on your particular needs.
If you find yourself in this kind of a situation, then rather than keep messing with the hosts file, you might want to invest in an excellent program such as Little Snitch. Here's the MacUpdate URL:
The price is a bit steep -- currently $30.00 -- but many Mac users have found it to be a worthy investment. I use it all the time.
In a word, Little Snitch protects your privacy by monitoring all outbound requests from your computer. In other words, anytime an app attempts to make a TCP/IP request to anywhere on the Internet, Little Snitch will warn you with a dialog window, and will offer you a variety of options to choose from, such as letting the request through permanently, letting the request through temporarily, blocking the domain permanently, blocking the domain temporarily while the app is running, blocking just a particular port, etc. Little Snitch keeps all of your personal settings stored in a "rules" file, which you can append or edit as needed from within the program.
Anyway, if it is within your budget, you might find Little Snitch to be a worthy investment. I have, and so have many others.
WordWeaver, I believe that’s the most thorough response I’ve ever gotten on this site! I feel like a pro now. Thanks a bunch — I’ll give your instructions a try forthwith.
Well, gee, GeoProf, what else did you expect from a long-tongued writer such as I? :) :)
Seriously, I write often long-winded articles concerning my Christian faith on the Endtime Prophecy Net website. And yes, that is a very shameless plug. ;)
There are currently no troubleshooting comments. If you are experiencing a problem with this app, please post a comment.
Please login or create a new MacUpdate Member account to use this feature
Watch Lists are available to MacUpdate Desktop Members Upgrade Now
Download and auto-install
using MacUpdate Desktop. Save
time moving folders and cleaning-up.
Hosts is a system preference pane to manage your hosts file.
Hosts add a preference pane to your system preferences which lets you toggle your host file entries on and off, as well as add and remove them.
Hosts.prefpane likes to keep your hosts file clean. When an entry is toggled off, it is not commented out in the hosts file, but instead stored in the app's preferences storage. This means you will have to uncomment all your unused host entries and untoggle them in the prefpane if you want to use them. Comments are treated as comments and will never show up in the list of host entries!
Ofcourse Hosts.prefpane will detect edits you made to the /etc/hosts directly and merge them into the listing.
Backups of your hosts file is made in ~/Library/Application Support/Hosts. The backup or your hosts file from before you started using Hosts.prefpane is called hosts.orig and each session a backup is made called hosts.session.
The default host entries that are needed by the OS are hidden and can not be edited using Hosts.prefpane.
+49
Madmacmad reviewed on 08 Jan 2012
The best hosts file editor ;-)
Why so late ?
P.S. Req: able to switch between hosts files like GasMask ;-)
would be perfect for Mobile workspace...
thxxx anyway
prisious reviewed on 31 Aug 2011
+5
exilederek reviewed on 26 Aug 2011
-1
+3
+60
It is little apps like these which make the Mac even more enjoyable to use, as they convey the spirit and vision of Steve Jobs himself. Our Mac computers shouldn't be viewed as challenges to use. Their underlying complex technology shouldn't scare us off. Apps like this one make sure that it doesn't.
On the other hand, if you do prefer to use the Terminal, following are the steps that you can use to edit your hosts file:
1. Open the Terminal application and paste in the following:
sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit /etc/hosts
2. Enter your password when requested to do so.
3. The Hosts file will open in a separate TextEdit window.
4. After making your changes, save the Hosts file by typing "Command-s".
5. Run the following command in the Terminal in order to flush your cache:
sudo dscacheutil -flushcache
5. Type "exit" to leave the session.
6. Shut down the Terminal app.
+152
Future thanks if you have time to instruct me further, and if you don’t, thanks for the tutorial you’ve already given us!
+1
+60
When you open the hosts file, at the very least, you will find an entry which says the following:
127.0.0.1 localhost
Whatever you do, do NOT remove that entry, as it is a loopback which your OS requires.
Basically, when you block a domain, what you are actually doing is creating a loopback so that the HTTP request, or whatever kind of request it is, never even leaves your machine; rather, the request is looped back to your machine, and never goes anywhere. That is what the 127.0.0.1 IP address does. That represents your machine.
So, if you want to block certain domains, you would simply add new entries to THE BOTTOM of your hosts file, AFTER everything else that may already be in there.
You would place one entry on each line, hit your return key, and then add another one.
Here is an example:
127.0.0.1 CrazySpammers.org
127.0.0.1 microsoftmaniacs.com
127.0.0.1 www.hackers-haven.net
127.0.0.1 www.EvilSpoofer.info
As you can see, you simply type "127.0.0.1", followed by a space, followed by the domain that you wish to block.
I believe that it may also be okay to use a tab instead of a space after the 127.0.0.1
Once you have added all of your entries, simply save the file and close it.
Of course, you may want to make a backup copy somewhere else on your hard drive, or on some other medium.
Note: I am not sure why, but when I just tried to follow my own instructions in the Terminal, I kept getting an error message. I don't know if it is because I am using Lion now, or if it is due to some other reason.
If you do encounter any error opening the "hosts" file, assuming that you have admin privileges on your computer, you can always open it manually as well.
To do this, you will need to make invisible System files and folders visible first. You will find a number of apps here on MacUpdate which will do this for you, such as MacPilot, iShow Invisible, TotalFinder, and a zillion others.
Once you have made your System files and folders visible, at the top level of your startup volume, look for the "etc" folder. It will probably be an alias, and will have a little curved arrow in the bottom left corner of it. Depending on what version of the Mac OS you are using, the folder may also possibly be dimmed, which indicates that it is invisible, I believe.
Once you open the "etc" folder, you will find the "hosts" file inside; rather, you will find an alias of the hosts file. The REAL hosts file is in private/etc/hosts.
If you prefer to open the hosts file with a particular text editor -- I use BBEdit -- then right click the hosts file and select the "open with" option.
At this point, depending on the ownership and permissions on the hosts file, you may possibly be requested to authenticate by providing your admin password.
Once the hosts file is open, simply follow my steps above for adding the domains that you wish to block.
I do want to mention one other thing.
Using the hosts file to block domains is a permanent thing. Once you add a domain in there, that domain will be permanently blocked until you remove it from the hosts file.
For example, if you add www.apple.com to your hosts file, you can forget about trying to go to any of Apple's websites. :)
There are times when you do not always want to block an IP or domain name permanently. There are also times when you may also want to only block certain ports that a domain uses. And there are many other possibilities as well, depending on your particular needs.
If you find yourself in this kind of a situation, then rather than keep messing with the hosts file, you might want to invest in an excellent program such as Little Snitch. Here's the MacUpdate URL:
http://www.macupdate.com/app/mac/10426/little-snitch
The price is a bit steep -- currently $30.00 -- but many Mac users have found it to be a worthy investment. I use it all the time.
In a word, Little Snitch protects your privacy by monitoring all outbound requests from your computer. In other words, anytime an app attempts to make a TCP/IP request to anywhere on the Internet, Little Snitch will warn you with a dialog window, and will offer you a variety of options to choose from, such as letting the request through permanently, letting the request through temporarily, blocking the domain permanently, blocking the domain temporarily while the app is running, blocking just a particular port, etc. Little Snitch keeps all of your personal settings stored in a "rules" file, which you can append or edit as needed from within the program.
Anyway, if it is within your budget, you might find Little Snitch to be a worthy investment. I have, and so have many others.
+1
+152
-1
+60
Seriously, I write often long-winded articles concerning my Christian faith on the Endtime Prophecy Net website. And yes, that is a very shameless plug. ;)
A1 rated on 28 Aug 2011
+5
exilederek rated on 26 Aug 2011