Microsoft Windows

How to block a website using hosts file

1. Create a copy of hosts file (backup) (hosts file location in Windows 7: %windir%\System32\drivers\etc\)

2. Run notepad as administrator.

3. Create a new text file.

4. Open hosts file for editing and copy its contents .

5. Paste hosts file contents into your new text file.

6. Delete hosts file from %windir%\System32\drivers\etc\.

7. For each site that you want to block, you have to enter a new line like this:
127.0.0.1 www.myblockedsite.com

8. Remember that myblockedsite.com and www.myblockedsite.com are completely different and you will need to add an entry for both.

9. Save your new file as hosts into %windir%\System32\drivers\etc\.

You have to delete hosts file and recreate it, otherwise your new rules will not be activated in Windows 7.
If you still can’t make hosts file work, open cmd as administrator and run this command:

ipconfig /flushdns