Self-Help Blog Post:

Avoiding Distractions on the Web - How to Block Websites Using Your Hosts File

Post Below
5/24/2009 - Avoiding Distractions on the Web - How to Block Websites Using Your Hosts File (Self-Help - Productivity)


   ▲ Top  ▼ Bottom  △ TOC
Avoiding Distractions on the Web - How to Block Websites Using Your Hosts File
Sunday, May 24th, 2009
03:12:36 GMT


If you're trying to get useful things done while you're on the internet, but find yourself habitually wandering over to distracting websites like forums, YouTube, or web-based email, you might like to use the following instructions (or an adaptation of them, if you're not a Windows user) to block any sites you want from appearing in your web browser even if you try to go to them.

In not only Windows but other platforms, there's something called a hosts file which allows you to block sites. The way it does this is by making it so any attempts to access anything at certain domain names are redirected to some other IP address.

The location of the hosts file can vary, but, if you're a Windows XP user like me, you might find it in this folder:


If the hosts file isn't at that location, you can look in the Wikipedia article Hosts file for some other possible folders/file paths where it might be. (Alternatively, you can search the web for a different source of info which is more trustworthy than Wikipedia, the encyclopedia that can be edited by anyone).

In Windows, you can navigate to the above file path simply and easily by opening Internet Explorer, copying and pasting the above file path into the address bar, and pressing Enter on the keyboard.

Make a duplicate of your hosts file, so you can put it back the way it was in case you mess anything up. (In Windows, this can be done by single-clicking the file, pressing Ctrl and C at the same time on your keyboard, then pressing Ctrl and V at the same time on your keyboard. A new file titled "Copy of hosts" should appear).

If your hosts file is set to be read-only, you'll have to change that before you can edit it. In Windows, right-click on your hosts file and choose Properties, and then make sure there's no checkmark in the box that says "Read only".

Next, open the hosts file with a plain text editor like Notepad. To block YouTube, add some lines like these.

(You can put either spaces or tabs between the and the domain name).

Save the file, and restart your web browser. Now, you won't be able to reach YouTube, because all your web browser's requests for anything at or will be redirected to, the localhost IP address - your own computer.

Unless you're running web server software on your computer for some reason (such as to run Astroblahhh Desktop or the Astrosorting Music Organization Database (AMODB)), you'll only reach a blank page.

If you want to stop blocking YouTube without deleting the above lines altogether, then, you can put some pound signs at the beginning of the above lines, like this:


Then, if you ever want to block YouTube again, you can just delete those pound signs.

Another tip - don't make it too easy for yourself to access and edit your hosts file. If you're using a particularly nice plain text editor like my favorite, NoteTab Light, you might be able to bookmark the hosts file. But, it's better not to, because that would make it too easy to unblock the sites you want to avoid.

   ▲ Top  ▼ Bottom  △ TOC