Windows 10 and 11 offer a variety of ways to edit the hosts file. This article will cover how to edit the hosts file on Windows 10 or 11. To edit the hosts file on Windows 10 or 11:

  1. Open the Start menu and type “cmd” (without the quotes) and hit enter.
  2. Type “netstat -an” (without the quotes) and hit enter.
  3. If you see a list of all active TCP/IP connections, your computer is connected to the internet, and your computer is not currently in use, your computer will not show any results from this command. If you see a list of all active hostnames, your computer is connected to one or more networks, and your computer is currently in use, this command will show results for all active hostnames on those networks. If you see only inactive hostnames, your computer is not connected to any networks and is not currently in use.
  4. Type “netstat -p” (without the quotes) and hit enter.
  5. The output from “netstat -an” should now look like this: tcp 0 0 0 192 .168 .1 .0 :443 tcp 0 0 1 192 .168 .1 .0 :443 tcp 0 0 2 192 .168 .1 .0 :443 tcp 6 12 3 192 .168 .1 .0 :443 udp 6 12 3 192 .168 .1 .":19200" If you are seeing only inactive hostnames, it means that there are no active TCP/IP connections on that network or that there are no active hostnames on that network but your computer is still connected to one or more networks which are allowing you to view these results because they are part of an Active Network Listing (ANL). To view an ANL for a specific network: 1) open Network Connections in

What Does the hosts File Do?

When you type in a regular web address to access a website, like google.com, your PC doesn’t automatically know how to connect. It needs the correct IP address associated with the web address in order to make a connection.

The hosts file is the first place your PC will check to find an IP address for a website, but by default, the hosts file doesn’t contain any. If your PC can’t find an IP address in the hosts file, it checks the DNS cache or connects to a DNS server. When a web address and an IP are inserted into the hosts file, it will provide that information to your computer any time you try to connect to that web address.

If the hosts file tells your computer to find a web address at an IP address that won’t connect — like 0.0.0.0 — it blocks access to the website.

The Windows hosts File Location

The hosts file is located in “C:\Windows\system32\drivers\etc” on both Windows 10 and 11. You need administrative permissions to edit it, which means that you can’t just open it in a normal Notepad window.

How to Edit the Windows hosts File

You can edit the hosts file with any text editor. There are a variety available, but both Windows 10 and 11 come with Notepad.  Avoid using a word processor — the differences between Notepad and a word processor like Wordpad can sometimes cause problems.

You’ll need to run Notepad as administrator to edit the hosts file. To do this on Windows 10, click the start button, type “notepad” into the search bar, and then on the right, click “Run as administrator.”

Running Notepad on Windows 11 is the same process as Windows 10, except “Run as administrator” is not displayed immediately. Click on the start button, and then type “Notepad” into the search bar. On the right-hand side, click the small downward-facing arrow to reveal more options.

Then click “Run as administrator.”

Once Notepad is open, click on File > Open, and navigate to “C:\Windows\System32\drivers\etc”

Notepad is set to look for “.txt” files by default, so you’ll need to set it to look for “All Files” in the drop down menu instead. Then, click the hosts file and hit open.

Once the hosts file is open, you can start adding lines to block websites. The lines that go into the hosts file can be broken up into three basic components, each separated by at least one space.

The IP Address – This tells your PC where to look for a website. The Web Address – This is the website address you want to block. The Comment – Where you describe what the line does. The comment must have a hashtag preceding it.

Once you’re done adding lines, click File > Save to save your changes. There shouldn’t be a popup after you click save. If there is, it means Notepad does not have administrative access, and that you need to close Notepad and run it as administrator. Once you’ve saved successfully, go ahead and exit Notepad.

There are two addresses, 127.0.0.1 and 0.0.0.0, that are commonly used in the hosts file to block traffic. There are significant differences between 127.0.0.1 and 0.0.0.0, but in most cases either will work. Rarely, a program running on your PC might have problems if you use 127.0.0.1, so it is best to stick with 0.0.0.0.

If You Can Still Connect to Blocked Addresses

Recent versions of Google Chrome, Mozilla Firefox, and Microsoft Edge all use DNS over HTTPS (DoH) by default. DNS over HTTPS works the same way as a regular DNS server, however DNS over HTTPS encrypts your queries to boost your privacy. Encrypting your queries means that third parties can’t tell what requests you’ve sent to a DNS server, or how the server responds.

When DNS over HTTPS is enabled in a browser, the browser bypasses the normal DNS client in Windows 10 and 11. That means the browser ignores the hosts file entirely and uses a secured DNS server specified by the browser instead, so any addresses you attempt to block using the hosts file will be accessible. If you want to use the hosts file to block web browser traffic, you’ll need to disable DNS over HTTPS in your browser.

Fortunately, you can enable DNS over HTTPS on Windows 11. That will allow you to use the hosts file to block addresses while maintaining the advantages of DNS over HTTPS.

RELATED: How to Enable DNS Over HTTPS on Windows 11