Advertisement

How To

How to edit your hosts file in Windows 10 and 11

How to edit your hosts file in Windows 10 and 11
douglasfakler

douglasfakler

  • Updated:

There are plenty of good reasons to restrict your PC from accessing dubious websites. From unwanted spyware to malicious viruses, some web domains are not worth the risk. As soon as your hosts file connects to a troublesome site, your computer is fully open to attack. The good news is that both Windows 10 and Windows 11 offer the ability to edit your hosts file to block annoying or dangerous websites from accessing your PC.

What is the purpose of a hosts file?

The hosts file is the location your PC checks when first connecting to a website. If you have a custom IP address stored in your hosts file, the PC will connect to the specified IP address instead of the typical DNS server readout broadcast by the website. By assigning a false IP address such as 0.0.0.0 to a website in your hosts file, you can prevent your PC from ever accessing the website’s true IP address.

  1. How to edit the Windows 10 and 11 hosts file

    Be sure to use a text editor such as Notepad when editing the hosts file.

    To edit your hosts file, you will need to use text editing software like Notepad. Please note that text editors are different from word processors such as Microsoft Word or Google Documents. You need a text editor to take specific advantage of coding functionality. For the sake of simplicity, use Notepad since it is already installed on Windows by default.

  2. Run your text editor as an administrator

    Click run as administrator in Windows 11.

    On Windows 10, simply right-click on Notepad and select run as administrator to open a new instance of the program. The process is a bit more involved in Windows 11.

    Type Notepad into the search bar at the bottom of the screen. When Notepad appears in the preview window, click on the downward-facing arrow below the icon. From the new menu that appears, select run as administrator.

  3. Find your hosts file

    You will find your hosts file in the drivers folder of the system32 directory.

    The hosts file is located at C:\Windows\System32\drivers\etc. You must also set Notepad to search for all files from the drop-down menu next to the search bar. Once all files are visible, you will see the hosts file in the specified directory as pictured.

  4. Add lines to block websites

    Once you have your hosts file open in a text editor, you can type lines of code to block websites. Each line is broken into three sections.

    1. The IP Address: This tells the PC where to go.

    2. Web address: This is the typed name of the website you are blocking.

    3. The Comment: This explains what the line does. It requires a hashtag behind it.

    Using the picture above as reference, type a line of code for all the websites you wish to block. You can even copy this example line of code to block Facebook:

    0.0.0.0.facebook.com#This blocks Facebook.com

  5. Save and confirm your changes

    Be sure to click File, then Save before closing your hosts file. This finalizes all the changes you made today. If you get a pop-up when trying to save, you need to run your text editor in administrator mode as shown in step 2.

Browse the web without intrusions

As big tech companies continue to push the envelope of how much data they wish to collect, blocking websites that you don’t use is a huge boon to your privacy. If you haven’t used a social media platform in months, consider blocking it to reduce how often your PC is tracked. Blocking access to inappropriate websites is also a terrific way to enact parental controls that your kids will likely have no clue how to disable. Regardless of why you choose to block harmful websites, having more control over how your PC connects to the web is always a good thing.

Interested in how other users are adapting to Windows’ newest operating system? Check out our article on the reception of Windows 11.

douglasfakler

douglasfakler

Ever since his brother brought home the original PlayStation, Doug Fakler knew he would be a gamer for the rest of his life. He has been glued to the screen with a controller in hand for over 20 years. While he will always acknowledge that gameplay is king, he's equally interested in the stories that can be told through interactive means. This inspired him to earn a bachelor's degree in Game Design from Full Sail University in 2015.

Latest from douglasfakler

Editorial Guidelines