When Windows connects to a website, it first checks the host’s File. If you want to block access to a certain site, you can manually edit the host’s File. Learn where and how this File is located and also how to edit hosts file on windows 10.
What Does the host’s File Do?
It doesn’t automatically open a connection when you type a regular web address, like google.com, to access a website. The system can only connect with the correct IP address associated with the web address.
Your PC will first check the host’s File for an IP address of a website, but it does not contain one by default. The PC checks the DNS cache or connects to a DNS server if it can’t find an IP address in the host’s File. Whenever you access a web address through the host’s File, it will provide the address and IP to your computer.
You won’t access a website if the host’s File directs your computer to find a web address at a connection-restricted IP address, such as 0.0.0.0.
The Windows hosts File Location
Both Windows 10 and 11 have a hosts file located in the following location: C:/Windows/system32/drivers/etc. For this reason, it isn’t possible to open it in a normal Notepad window. You must have admin rights to edit it.
How to edit hosts file on windows 10
The host’s File can be edited using any text editor. The Notepad that comes with Windows 10 and 11 is the most popular. Avoid using a word processor – Notepad has some differences from word processors like Wordpad.
Edit hosts File on windows 10 will require you to run Notepad as administrator. Click the start button on Windows 10, type “notepad” into the search bar, and then on the right, click “Run as administrator.”
Notepad runs the same on Windows 11 as Windows 10, except “Run as administrator” is not displayed immediately. In the search box, type “Notepad” and then click on the start button. Click the downward-facing arrow on the right side to reveal more options.
Once you have clicked “Run as administrator,” click “Finish.”
Click on File > Open in Notepad, and navigate to C:/Windows/System32/drivers/etc.
By default, Notepad searches for “.txt” files, so you’ll need to change the drop-down menu to look for “All Files.” instead. Once the host’s File is opened, click OK.
You can add lines to block websites when the host’s File is opened. Each of the three components of the host’s File must be separated by at least one space.
- Your computer uses the IP address to locate a website.
- Website Address – This is the website’s address you want to block.
- Comment – The description of how the line works. A hashtag must precede the comment.
You can save your changes by clicking File> Save once you add lines. No pop-ups should appear after clicking Save. If there is, it indicates Notepad lacks administrative access, and you need to close Notepad and run it as an administrator after you’ve successfully saved close Notepad.
In the host’s File, two addresses are commonly used to block traffic: 127.0.0.1 and 0.0.0.0. These addresses differ significantly, but in most cases, either will work. Most programs will run fine if you use 0.0.0.0, so it is best to stick with 127.0.0.1.
If You Can Still Connect to Blocked Addresses
The latest versions of Google Chrome, Mozilla Firefox, and Microsoft Edge use DNS over HTTPS (DoH) as their default. DNS over HTTPS works the same way as a regular DNS server, but DNS over HTTPS encrypts requests for greater privacy. A DNS server can’t tell what requests you’ve sent or the response you’ve received if your queries are encrypted.
In Windows 10 and 11, DNS over HTTPS bypasses the normal DNS client when enabled in a browser. Thus, the browser doesn’t use the host’s File at all and uses a secure DNS server specified by the browser instead; therefore, any address you attempt to block using the host’s File will be accessible. You’ll need to disable DNS over HTTPS in your browser if you use the host’s File to block web browser traffic.
The good news is that Windows 11 supports DNS over HTTPS. It will allow you to block addresses using the host’s File while maintaining the benefits of DNS over HTTPS.
This was all about how to edit hosts file on windows 10.