Tuesday, 5 May 2015

Block website using Host file

It`s a simple way to block website using hosts file. In windows 7 it`s located at "C:\Windows\System32\drivers\etc". Hosts file contain ip address and hostname. 



To edit host file you must have administrative privilege.

  • Open notepad with  administrative privilege. Click on start > All Programs> Accessories. In Accessories right click on notepad and click on "Run As Administrator".





  • In Notepad click on File menu and Click on Open..(Ctrl + O). Now browse for host file with above path and open the "hosts" File. You may also drag and drop hosts file on notepad.

Note : Hosts file contain ip address and hostname. Lines starting with d character are commented line and which is ignore by the system.

  • Suppose you want to block website abc.com then add line like "127.0.0.1 abc.com" in hosts file. IP address 127.0.0.1 is IPV4 loopback address. "localhost" resolves to the loopback address. That means you mapped abc.com to your system so you cant access to abc.com.