- dotTech - https://dottech.org -

How to block websites in Windows 8 using the HOSTS file — be sure to disable Windows Defender first [Guide]

Using Windows’ HOSTS file is a quick and painless way to block websites (such as Facebook, ad networks, or malicious websites) on your machine. In the past blocking websites using the HOSTS file was (is) as easy as editing the HOSTS file and adding the websites/servers you want to block. In Windows 8, however, it is a bit different. You see one of the many changes Microsoft [1] has made in Windows 8 [2] is introducing a native anti-virus/anti-malware security program. Called Windows [3] Defender (it is essentially Microsoft Security Essentials), one of the things this security program does is protect the HOSTS file from modification. For most users this protection by Windows Defender is a good thing; it prevents malware from hijacking your HOSTS file without your knowledge. For users that want to modify the HOSTS file, however, this is a roadblock in blocking websites with the HOSTS file. If you are confused on how to block websites/servers in Windows 8 with the HOSTS file, this guide is here to help. (The following method works for Windows 8 desktops, laptops, and tablets.)

How To Block Websites/Servers/Ads With The HOSTS File In Windows 8

Step One — Exclude HOSTS From Windows Defender Protection

One of the ways to turn off Windows Defender’s protection of the HOSTS file, and thus allow you to edit it, is by disabling Windows Defender altogether. However, for 99.99% of Windows users there is no reason to disable Windows Defender; Windows Defender provides basic, much-needed native protection to Windows 8. If you want to disable Windows Defender so you can use a different security program, such as avast! or Avira or AVG, don’t bother — Windows Defender automatically disables itself when it detects a third-party security solution is installed. Therefore, the solution  to the Windows-Defender-is-blocking-access-to-HOSTS-file problem is not disabling Windows Defender but rather adding the HOSTS file to the exclusion list in Windows Defender.

To exclude the HOSTS file from Windows Defender protection, do the following:




Once you have done what is described above, you have successfully disabled Windows Defender’s protection of Window 8’s HOSTS file. Proceed to the next step in this guide to learn how to edit the HOSTS files to block websites.

Step Two — Modify The HOSTS File

Once you disable Windows Defender protection, editing the HOSTS file on Windows 8 is the same as on previous versions of Windows. Do the following:








Add whatever you want to block at the end of the HOSTS file in the format of [website URL]. For example, if you want to block Facebook you would add “ facebook.com” (without the quotes):


Add as many websites, servers, ad networks, etc. that you want to block.

If you don’t want to manually add thousands of websites to block, there is a very popular HOSTS file block list maintained by MVPS that you can copy and paste into your HOSTS file to block ads and known malicious websites. To use MVPS’s host file as your own, go to http://winhelp2002.mvps.org/hosts.txt [17] and copy all the text starting from “# [Start of entries generated by WinHelp2002]” and ending at “# [end of entries generated by WinHelp2002]”. Then paste it at the end of your computer’s/tablet’s HOSTS file and save it.


Using the HOSTS file to block websites is one of the best ways to block websites, servers, ads, etc. in Windows. Yes it does take some work as opposed to using something like an ad blocker in your browser [18] but its native nature (i.e. it is a built-in Windows feature) makes it extremely desirable. Stay safe and enjoy!