How to find and edit the hosts file in Windows 11

There are many ways to find an IP address in Windows 11, but what if you want to find and edit the hosts file in Windows 11? The hosts file is a powerful way to restrict or allow access to a specific website on your computer. This allows you to add an IP address for a specific domain and the browser will point to that specific address. Therefore, we have compiled an excellent guide on how to find and edit the hosts file in Windows 11. Also, we have included an explanation of what the hosts file does in Windows 11 so that you can understand the concept in simple terms. On that note, let's move on to the steps you need to follow.

Find and edit the hosts file in Windows 11 (2022)

In this guide, we have mentioned the location of the hosts file in Windows 11, so you can easily edit it. Moreover, we have also explained what the hosts file is and what it is used for on your Windows 11 PC.

What is the hosts file in Windows 11?

When you open a website on your PC, the browser looks up the IP address of the domain name from the DNS server. Before doing so, however, it first consults the "hosts" file on your Windows PC to determine if the user has specified an IP address for a specific domain. If you provide a website with a non-existent IP address (for example, 0.0.0.0), the website will not open and will be effectively blocked. Basically, the hosts file contains a list of all the websites that you have blocked on your PC.

Having said that, if you are using one of the popular DNS servers in your browser, the browser will ignore the hosts file. It will directly contact the DNS server or DNS cache to get the IP address of the website (domain name) you are visiting. To avoid this situation, we suggest enabling DNS over HTTPS (DoH) in Windows 11 in System Settings. This ensures that you get all DoH encrypted protection and also takes the hosts file into account. In this case, the websites mentioned in the hosts file will be blocked and you will also get encrypted DNS communication.

So, in summary, the hosts file in Windows 11 allows you to block websites by giving them a fictitious IP address. This is a simple and effective solution for users who want to restrict access to certain websites on their PC across all browsers.

How to find the hosts file in Windows 11

1. First, press the Windows 11 keyboard shortcut “Windows + E” to open File Explorer. Double click here to open the "C" drive.

2. Next, go to the "Windows" folder.

3. After that, go to the system32 -> drivers -> etc folder. Here you will find the "hosts" file which we need to edit. It will be of type "File", not "Calendar".

4. If you don't see the "hosts" file in this folder, click "View" in the top menu and click "Show". Now select Hidden Items. This will show all hidden items including the "hosts" file.

Windows 11 hosts file location

You can go to the following address - "C:Windowssystem32driversetc" to find the hosts file in Windows 10 and 11. Although you need administrator rights to edit the hosts file in its original location, we will take a slightly different route. So keep reading.

How to edit the hosts file in Windows 11

1. First make a copy of the hosts file somewhere else, such as your desktop. This will allow you to easily and without administrator rights edit the Hosts file in Windows 11.

2. Now navigate to the copied hosts file, right click on it and select "Open With". Here select "Notepad".

3. To block websites using the "hosts" file in Windows 11, add a line at the bottom following the syntax below. Here you are pointing twitter.com to 0.0.0.0 which is a non-existent IP address. The sentence after the # is a comment and is optional. You can add as many websites to the hosts file as you want using the syntax below.

0.0.0.0 twitter.com #Your PC will block twitter.com

4. Now click "File" in the top menu and select "Save".

5. After that, copy and move the modified "hosts" file to the "etc" folder to replace it. It will ask for administrator permission and you need to click Continue.

6. Finally, open twitter.com and it will not open on your Windows 11 PC because the IP address of this website is mapped to a non-existent IP address. Here is how you can find and edit the hosts file in Windows 11 to block websites.

7. If you want to unblock a website, simply remove the line you added to the hosts file, or add # at the beginning of the line to turn the entire text into a comment. This will make the command ineffective. Now move the modified hosts file back into the "etc" folder for the changes to take effect.

Frequently Asked Questions (FAQ)

What is the Hosts file in Windows 11?

The hosts file essentially contains a list of websites that you want to block on your PC. You can also use the hosts file in Windows 11 to point a domain name to a specific IP address.

Where to find the Hosts file in Windows 11?

The hosts file in Windows 11 is located at C:WindowsSystem32drivesetc.

What is the Hosts file for in Windows 11?

You can use the hosts file in Windows 11 to block websites on your PC by giving them a broken IP address.

Can we enable DNS over HTTPS with a Modified Hosts file?

Yes, you can use DNS over HTTPS and route traffic to the ghost file at the same time. However, you need to enable DNS over HTTPS in your Windows settings, not through your browser.

Edit hosts file to block websites in Windows 11

Here is how you can find and edit hosts files in Windows 11. To reiterate, if you want your computer to look for blocked hosts on your Windows PC, you will have to disable DNS over HTTPS in your browser. And if you've enabled DNS over HTTPS in your PC settings, you don't have to do anything. Windows 11 will take into account the hosts file. However, this is all from us. If you want to find the Windows 11 Startup folder in Windows 11, use our linked guide. And to find your MAC address in Windows 11, we also have a handy guide. Finally, if you have any questions, please let us know in the comments section below.

Related posts