What is a Hosts File? A Comprehensive Guide to Modifying it in Windows 10 or 11

Learn how to modify the hosts file in Windows 10 or 11 with our comprehensive guide. Understand what a hosts file is and its importance in managing network connections. Start optimizing your system today! Once, when the internet was cut off from my laptop, I became deathly bored and kept digging through the mysteries and secrets of the Windows system until relief came. I came across strange files that I did not know what their usefulness was, and the most prominent of these files was a file called "Hosts", which I thought of deleting because when I double-clicked on it, it did not open, but I said to myself that there is no need for such actions that I might regret later, with the passage of time and the recurrence of similar situations , I listed the importance of the hosts file and remembered this situation and smiled! Simply this file is the first thing that the Windows system resorts to when connecting to a website on the Internet, and therefore modifying it may sometimes come with great benefit, let's dig deeper...



What is the hosts file and why is it important?

You can liken the hosts file to a phone book; It contains a large number of numbers, but the numbers here mean the addresses of the sites or their IP Address. To know its importance, you have to know the way your computer connects to the Internet. With a simplified explanation, when you open the browser and write in the address bar www.google.com and press Enter, the computer does not automatically connect to the Internet directly, but searches its records first for the IP address of the site you want to access, and what are the computer records? Exactly, the hosts file; After you write the name of the site in the search field and press Enter, the computer searches in the aforementioned file for the IP address of the site so that it can access it, and in many cases the IP addresses are not stored in the hosts file, which forces the computer to search elsewhere, and this other place It is the DNS server or its DNS Cache.

When you write a site address in addition to the IP address in the hosts file, it will provide the browser or whatever program from which you are trying to access this site with this information as soon as you connect to this site address. Therefore, this ability can be used to permanently block access to a site on the computer.

For Windows 10 and Windows 11, the hosts file is usually located in [ C:\Windows\system32\drivers\etc ], but you need administrator rights to be able to modify it. As we mentioned, there are many uses for the hosts file, but the most important of them is that you can modify it to block sites that you do not want your device to enter, but a file of this importance does not have a Windows account to modify it, only those who have admin powers, and we will show you how to modify it now .

How to modify the hosts file
Method 1: Using Notepad



Believe it or not, you can edit this file using any text editing program. As with previous versions, Windows 10 and Windows 11 come with a pre-installed Notepad program, which we will use to modify the hosts file, and let's all unify the method so that no problem or error occurs. First, you will need to open the tool with administrator privileges, through the Start menu by right-clicking on the Notepad icon, then pointing the cursor towards the “More” option and pressing “Run as administrator”, or by searching, just press the Win + S keys ( Q) Together on the keyboard to display the search bar, then type "notepad" in the search field and then press Run as administrator from the results page.



Once the Notepad window appears, click on the File section of the toolbar at the top, then choose from the drop-down menu the “Open” option. From the new window, go to the hosts file path mentioned above and make the Notepad display “All Files” instead of searching for text files Only [as picture shown]. Then double-click on the hosts file to display its contents in Notepad so that you can modify it.



Lend me your attention now, dear reader; The hosts file has been opened and here you are seeing what you might describe as sorcery! But don't worry, it's simpler than it looks. To block any site you want now, I want you to scroll down and press Enter to create blank lines after the last line where we enter data that Windows translates to control access to sites. And let's assume here that you want to prevent your computer from accessing Facebook, so all you will do now is that you will type the following IP: 0.0.0.0 which translates as the "Block" command, after that leave a space and write facebook.com, then a space and write a comment preceded by the check box symbol, This comment is a description of what he just did. Here's the example in action:

0.0.0.0 facebook.com #This blocks facebook.com


For the numbers, it blocks any site, for the following it is the web address that we want to block (Facebook or any other site), and finally for the description preceded by the tick, it shows that Facebook is now blocked from your device. It should be noted that this part of the comment is not necessary, that is, it is sufficient to write the numbers followed by a space and then the name of the site to block it, but this comment explains to you what you did and makes it easier for you in the future.

After you finish editing, click on the File section on the top bar of Notepad and then click on the Save option to keep your new modifications. By the way, if you get an error window after clicking on Save, you must have opened Notepad in normal mode and did not give it administrator permissions. Once your changes are saved, you can close Notepad.

Method 2: Using Microsoft PowerToys



There is another easier way to modify the hosts file in case you find the previous method a bit difficult. Here we will rely on the Microsoft PowerToys program, which is a well-known program that provides a set of help features to increase productivity or add more customization in the user interface. Simply put, this program represents one of Microsoft's best tools as a "means" to improve the way we use Windows on a daily basis. Through this tool, it is possible to perform many tasks such as changing the functions of keyboard buttons , launching programs quickly , organizing open windows to equal sizes, adjusting the dimensions of a batch of images with one click, knowing what prevents deletion or modification of the file , in addition to extracting any text from the images. .

You can also modify the Hosts file using this program. All you need to start is to install PowerToys on your device, either through the Microsoft Store or by downloading the EXE file from the Microsoft site to install manually, then run the program and select from the side menu the Hosts File Editor tool and activate it by activating Click on the "Enable Hosts File Editor" button, then click on the "Launch Hosts File Editor" option. A window will appear where you can enter the data to be written in the hosts file, but in an organized and clear manner.



In any case, whether you choose to use the first or second method, if you modified the hosts file and blocked a site and tried to open it on the browser and were surprised that it opens with you, then by a large percentage the reason will be in the browser itself, whether Firefox, Google Chrome or Microsoft Edge, the new versions of These browsers overcome the method we just explained thanks to their support for DNS over HTTPS technology , so if you want to make the hosts file take control of your web browser again, you will need to disable this technology in your browser. It's very simple, just look in your browser settings for "Use secure DNS" option and disable it.

tags:

Hosts file Modifying hosts file Windows 10 hosts file Windows 11 hosts file Hosts file guide How to modify hosts file Comprehensive hosts file tutorial Understanding hosts file in Windows Hosts file configuration Customizing hosts file in Windows 10 or 11 Modifying DNS settings with hosts file Managing blocked websites with hosts file Hosts file location in Windows 10 or 11 Troubleshooting hosts file modifications Hosts file syntax in Windows
Comments