Windows 10: Block Websites using Hosts File in Windows

Discus and support Block Websites using Hosts File in Windows in Windows 10 Tutorials to solve the problem; How to: Block Websites using Hosts File in Windows How to Block Websites using Hosts File in Windows The Hosts file is used by the operating... Discussion in 'Windows 10 Tutorials' started by JohnErmilio, Jul 24, 2018.

  1. Block Websites using Hosts File in Windows


    How to: Block Websites using Hosts File in Windows

    How to Block Websites using Hosts File in Windows


    The Hosts file is used by the operating system to map human-friendly hostnames to numerical Internet Protocol (IP) addresses which identify and locate a host in an IP network. The hosts file is one of several system resources that address network nodes in a computer network and is a common part of an operating system's IP implementation.

    The Hosts file contains lines of text consisting of an IP address in the first text field followed by one or more host names. Each field is separated by white space (Tabs are often preferred for historical reasons, but spaces are also used). Comment lines may be included, and they are indicated by a hash character (#) in the first position of such lines. Entirely blank lines in the file are ignored.

    Using the Hosts file to block websites by domain is preferable to trying to use rules in Windows Defender Firewall to block IP addresses since websites will often use more than one IP address.

    This tutorial will show you how to block websites for all users on the computer using the Hosts file in Windows 7, Windows 8, and Windows 10.

    You must be signed in as an administrator to edit the Hosts file.


    If you find manually editing the Hosts file directly uncomfortable, you could use a free standalone program like BlueLife Hosts Editor to help make editing the Hosts file easier.



    CONTENTS:

    EXAMPLE: When you try to open websites blocked in Hosts file

    Block Websites using Hosts File in Windows [​IMG]

    Block Websites using Hosts File in Windows [​IMG]







    OPTION ONE [/i] Block Websites using Hosts File
    1 Perform the following actions to open Notepad using Run as administrator: (see screenshot below)
    A) Open the Start menu *Start.

    B) Click/tap on the Windows Accessories folder in All Apps to expand it open.

    C) Right click or press and hold on Notepad, click/tap on More, and click/tap on Run as administrator.


    Block Websites using Hosts File in Windows [​IMG]

    2 In Notepad, click/tap on File Alt + F in the menu bar, and click/tap on Open Ctrl + O. (see screenshot below)

    Block Websites using Hosts File in Windows [​IMG]

    3 Perform the following actions to open the Hosts file in Notepad: (see screenshot below)
    A) Browse to and open the C:\Windows\System32\drivers\etc folder from the navigation pane or address bar in the Open dialog.

    B) Select All Files (".") in the drop menu at the bottom right corner. This will allow you to see the hosts file listed.

    C) Select the hosts file.

    D) Click/tap on the Open button.


    Block Websites using Hosts File in Windows [​IMG]

    4 In the hosts file now opened in Notepad, make note of your localhost IP address (ex: "127.0.0.1"). You will need to use this while blocking websites in step 5 below. (see screenshot below)

    Block Websites using Hosts File in Windows [​IMG]

    5 Perform the following actions to add a website to be blocked: (see screenshot below)

    Each website you want to block must be added on a separate line.


    A) On a new line in the hosts file opened in Notepad, type your localhost IP address (ex: "127.0.0.1") from step 4.

    B) Press the Tab key to add space.

    C) Type the website address (ex: "www.google.com" or "www.facebook.com") you want to block.

    This will block all websites that start with this added domain (ex: "www.google.com" or "www.facebook.com").

    HTTPS sites will not get blocked unless you include www in its address.


    D) If you would like to add a comment about this blocked website, then press the Tab key to add space, press the pound key # to indicate this is a comment, and type the comment you want (ex: "To block Facebook").

    Comments are optional, and do not have to be added unless you would like to.


    E) Press Enter to start a new line.

    F) Repeat steps 5A to 5E if you would like to add more websites to be blocked.


    Block Websites using Hosts File in Windows [​IMG]

    6 When finished editing the hosts file in Notepad, click/tap on File Alt + F in the menu bar, and click/tap on Save Ctrl + S. (see screenshot below)

    Block Websites using Hosts File in Windows [​IMG]

    7 Close Notepad.

    8 If the websites you added to the host file are not being blocked immediately, then restart the computer to apply.





    OPTION TWO [/i] Unblock Websites Blocked in Hosts File
    1 Perform the following actions to open Notepad using Run as administrator: (see screenshot below)
    A) Open the Start menu *Start.

    B) Click/tap on the Windows Accessories folder in All Apps to expand it open.

    C) Right click or press and hold on Notepad, click/tap on More, and click/tap on Run as administrator.


    Block Websites using Hosts File in Windows [​IMG]

    2 In Notepad, click/tap on File Alt + F in the menu bar, and click/tap on Open Ctrl + O. (see screenshot below)

    Block Websites using Hosts File in Windows [​IMG]

    3 Perform the following actions to open the Hosts file in Notepad: (see screenshot below)
    A) Browse to and open the C:\Windows\System32\drivers\etc folder from the navigation pane or address bar in the Open dialog.

    B) Select All Files (".") in the drop menu at the bottom right corner. This will allow you to see the hosts file listed.

    C) Select the hosts file.

    D) Click/tap on the Open button.


    Block Websites using Hosts File in Windows [​IMG]

    4 In the hosts file now opened in Notepad, perform either step 4A or 4B below to unblock a website:
    A) Add the comment # symbol in front of the line of the blocked website you want to unblock, and add a space after the # symbol. (see screenshot below)

    Using the comment # symbol can be useful when you want to sometimes block and unblock a website on demand and don't have to add and remove the website each time. You can just add and remove the comment # symbol instead.



    Block Websites using Hosts File in Windows [​IMG]

    OR

    B) Delete (remove) the line of the website you want to unblock. (see screenshots below)

    Block Websites using Hosts File in Windows [​IMG]


    Block Websites using Hosts File in Windows [​IMG]

    Block Websites using Hosts File in Windows [​IMG]

    C) Repeat step 4A or 4B if you would like to unblock more websites.
    5 When finished editing the hosts file in Notepad, click/tap on File Alt + F in the menu bar, and click/tap on Save Ctrl + S. (see screenshot below)

    Block Websites using Hosts File in Windows [​IMG]

    6 Close Notepad.

    7 If the websites are not unblocked immediately, then restart the computer to apply.

    That's it,
    Shawn


    Related Tutorials

    :)
     
    JohnErmilio, Jul 24, 2018
    #1
  2. pigulici Win User

    List website to block in host file

    So , recent I learn that I can block the ads on my pc if I put the ip address of that ads in the host file to go on 127.0.0.1, well I did not escape from all ads but I am not rely only on browser addons(take some work on cpu), also I like host idea because I can control it and block before enter on pc, not on browser, I put the list from here:
    http://winhelp2002.mvps.org/hosts.txt
    now I see another list who seems good too:
    http://www.malwaredomainlist.com/hostslist/hosts.txt

    I know this lists are not forever,I must check periodical for changes, but I want to know if are another, maybe, best list(updated periodical).

    Look like the one from malwaredomainlist.com it is to aggressive, even yahoo messenger will not connect, so I will stay with http://winhelp2002.mvps.org/hosts.txt for now, maybe athers will post their finds.
     
    pigulici, Oct 27, 2019
    #2
  3. Afees98 Win User
    Blocking sites with Hosts File


    Hello,

    I am trying to block all porn sites on the laptop that I let kids play on. I tried using the hosts file to block them, I found a huge list of porn sites to block. But when I tried to load other sites like Facebook, YouTube, etc. It will take forever to load as I believe it is checking the whole list of sites.

    Now what am wondering is there anyway of doing it and not have any difference with the speed of any other website? Because youtube should just come up with no issues. But with all those sites in the host file it takes forever.

    Windows 10 (by the way)

    Thanks!
     
    Afees98, Oct 27, 2019
    #3
  4. LGV
    LGV Win User

    Block Websites using Hosts File in Windows

    How To Block Facebook

    Step 1. Explore C:\Windows\System32\drivers\etc.
    Step 2. Look for a file named as hosts, then open it with Notepad.
    Step 3. At the bottom of the file, add the line as shown below:
    127.0.0.1 www.blockingsite1.com
    We have just shown you www.blockingsite 1.com as example only, replace it with the actual URL so that they are inaccessible to all.
    Step 4. Simultaneously if you have more websites that would like to be blocked, just press Enter and repeat step 3 to add additional URL until all desired websites are added. Now make “Enter” at the last line of the UR
    Step 5. Save and close the file.
    After doing the above formalities all websites that you have entered will be blocked with immediate effect. Definitely this theory will help you to prevent certain websites from being accessed by your kids or anybody else for any reason.
     
  5. Bree Win User
    How to Block Websites

    It should work as long as it is named just HOSTS without any file extension (and assuming you have written it correctly). Open a Command prompt and type the command:

    dir c:\windows\system32\drivers\etc\hosts*.*

    Your file should be shown as HOSTS with no extension. I suspect you'll find it still has an extension, .txt perhaps.
     
  6. How to block a website using hosts file?

    Hi Agriz,

    We appreciate the information that you have provided. However, this issue with blocking websites using hosts file can be best handled in our TechNet forums. We suggest that you post your concern in this

    link
    . From there, IT specialists will cater to your concern. Also, we can wait for other Community members to engage in this thread and provide you their insights regarding your concern which may help to get this resolved right away.

    Let us know if you need further help with any Windows issue.
     
    Jennifer Bri, Oct 27, 2019
    #6
Thema:

Block Websites using Hosts File in Windows

Loading...
  1. Block Websites using Hosts File in Windows - Similar Threads - Block Websites using

  2. blocking websites in any browser using local host or other method

    in Windows 10 Network and Sharing
    blocking websites in any browser using local host or other method: I'm interested in blocking content on a local machine, but now allowing the user to look up how to unblock this stuff. so for instance, if I want to block a local user, who operates their own machine, from going to this site: https://www.youtube.com/ , how exactly would I do...
  3. blocking website

    in Windows 10 Network and Sharing
    blocking website: how to block website on internet explorer and google chrome? on windows 10 https://answers.microsoft.com/en-us/windows/forum/all/blocking-website/6e2fe5e9-582b-4de8-ac74-ef1a698aa38b
  4. Windows 10 host file from Winhelp2002 won't block certain websites

    in Windows 10 Ask Insider
    Windows 10 host file from Winhelp2002 won't block certain websites: I installed the host file on http://winhelp2002.mvps.org/hosts.htm. Now I cannot block www.msn.com via host file. I tried running ipconfig /flushdns with nbtstat -R to force W10 load to load the new entries, aftering adding msn.com. The OS doesn't reconginze 0.0.0.0...
  5. Windows is blocking a website

    in AntiVirus, Firewalls and System Security
    Windows is blocking a website: I have both a PC and a Surface Pro with Windows 10 but cannot view a specific website on just my PC. How can I get Windows 10 to allow this website on my PC?...
  6. How to block a website in Windows etc/hosts?

    in Windows 10 Network and Sharing
    How to block a website in Windows etc/hosts?: I want to block a games website from my computer and on the internet, one suggestion was to edit /etc/hosts and put in these rules. C:\WINDOWS\system32\drivers\ etc\hosts 127.0.0.1 http://crazygames.com 127.0.0.1 http://www.crazygames.com But it does not work....
  7. block websites

    in Windows 10 Support
    block websites: hello. i have an annoying set of websites showing ads popping up each time I visit a specific page. now i have already got the extensions 'ad block' and 'ad block plus' running in the background but on these websites it does not seem to pick up on anything. i have added the...
  8. Using hosts file to block sites: Use 127.0.0.1 or 0.0.0.0 ?

    in AntiVirus, Firewalls and System Security
    Using hosts file to block sites: Use 127.0.0.1 or 0.0.0.0 ?: I've always blocked domain names in the hosts file by assigning the IP as 127.0.0.1 But I've been reading about the use of 0.0.0.0 instead. What's the difference? Is one better than the other? 101504
  9. Blocking sites with Hosts File

    in Browsers and Email
    Blocking sites with Hosts File: Hello, I am trying to block all porn sites on the laptop that I let kids play on. I tried using the hosts file to block them, I found a huge list of porn sites to block. But when I tried to load other sites like Facebook, YouTube, etc. It will take forever to load as I...
  10. Problem with blocking sites with hosts file

    in Browsers and Email
    Problem with blocking sites with hosts file: Hi I tried to block some sites in that way but although I cleared DNS cache (ipconfig /flushdns) ater editing the hosts file, I'm still able to access those sites. Googled about it but seems everything has done Ok and wonder why I can't use this method. I tested on...