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. how to block websites

    in Windows 10 Customization
    how to block websites: How do I block websites giving unwanted pop ups https://answers.microsoft.com/en-us/windows/forum/all/how-to-block-websites/8b2ed814-5423-40bc-b846-6399ce363e74
  3. Windows 10 blocking Websites?

    in Windows 10 Network and Sharing
    Windows 10 blocking Websites?: I have a new Dell laptop with windows 10 on it, Firefox and Kaspersky anti-virus. When I try to go to Hotmail (Outlook), it won't load at all. Netflix won't load and says I don't have a secure connection. Facebook gives me a partially loaded news feed (can't click on...
  4. 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...
  5. Website getting blocked

    in AntiVirus, Firewalls and System Security
    Website getting blocked: I have been using this website www.camsonline.com/COL_InvestorServices.aspx for many years. With a new computer with McAfee software also I have been using this for at least three months. But suddenly two days ago it says "WEB PAGE BLOCKED". I dont know why. What can I do to...
  6. How to Block Websites

    in Browsers and Email
    How to Block Websites: I have googled a bit and found software that can be used to block websites on a computer. I also found another way by using Windows which I would prefer. My problem is I must be doing something wrong. Here is the site that has the steps. How to block websites | PCWorld Here...
  7. 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
  8. Website Content Blocked

    in Browsers and Email
    Website Content Blocked: Morningstar.co.uk has been blocked in IE and Edge because it has not been signed by a valid security certificate. I have used this site for years without problem but the certificate warning is not in the usual format. Any ideas please? Could someone try and access this site...
  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...