How To Block Websites Like Facebook and Twitter on Your Computer

If you are system administrator at a school, college or office, then you must be looking for a good way to block social networking websites like Facebook, Twitter, Orkut etc. Or if you are a parent, then you may want to block certain websites from your computer so that you children don’t open them by mistake.

The best solution would be to use some commercial software to block these websites. Another way would be to configure a proxy filter at the network gateway. Both these solutions are the good ways to block websites. But if you are looking for a cheap or free way to block websites on your computer, which is also very easy to implement, then you should use HOSTS file to block websites.

What is HOSTS File?

HOSTS file is a text file used by an operating system like Windows to map an IP address to a host name. For example, if you open http://localhost in your web browser, Windows checks HOSTS file and takes you to IP address.

# This is an example of the hosts file localhost loopback

Block Websites on Your Computer Using Hosts File

To block any website on your computer, first open HOSTS file in a text editor like notepad. The location of hosts file depend upon your operating system,

  • For Windows NT/2000/XP/2003/Vista/7, it is %SystemRoot%\system32\drivers\etc\
  • For Windows 95/98/Me, it is %WinDir%\
  • For all flavours of Linux and unix, it is located at /etc/hosts
  • For Mac OS 9 and earlier, go to System Folder->Preferences
  • For Mac OS X, it is located at /private/etc/hosts

If you are on Windows vista or windows xp, go to click on start->run type, notepad %SystemRoot%\system32\drivers\etc\hosts, and press enter.


When the hosts file is open, just look for the line, localhost

Under this, add the name(s) of website(s) that you want to block, in the following format, websiteToBlock

For instance, if you wish to block twitter from your computer, then the following lines must be added to the hosts file,


After adding all the websites that you want to block, save the HOSTS file. Now open the blocked websites in your browser. You will not be able to open any blocked website now. To unblock the blocked websites again, remove those lines from hosts file.

Note that after adding the HOSTS file to block websites as explained above, if you are unable to save it, then you may have to open the HOSTS file as an administrator.

Check out the video below that explains how to block a website on your computer using HOSTS file: