We are all aware that DNS (Domain Name System) is the phone directory of the internet. But did you know that your PC’s host file can also serve as a directory for domain names? So, in this article, I will define the Hosts file, where it is located, and how to edit it on a Windows PC. It works on any version of Windows, including Windows 11, Windows 10, and any other version of Windows.
What Is Hosts File, Location, and How to Edit It
- What Is a Host File
- Why Modify Host File
- Where Is a Host File Located
- How to Edit a Host File
Editing the Host File is not risky, but please keep a backup of the original HOST file as a precaution. In case of any issue, you can replace it with a backup and fix the problem.
1] What Is a Hosts File in Windows PC
A Hosts file is a local file that maps domain names and their corresponding IP addresses. The operating system uses it to resolve domain names to their corresponding IP addresses when a user tries to access a website. It is present in all major operating systems and is a map for locating and recognizing IP hosts.
When you visit a website, your computer checks the Hosts file to see which IP address it connects to. If the data is missing, your internet service provider will search the DNS for the necessary resources to load the website.
2] Why Modify a Host File in Windows?
The HOSTS file can be edited to block access to specific websites by mapping their domain names to a non-existent IP address or to redirect traffic from one domain to another by mapping the domain name to a different IP address.
It’s an excellent tool that has its advantages and drawbacks, so make sure when you are editing it you know what you want to achieve.
The Hosts file is composed entirely of plain text. As a result, you can update it using any text editor, such as Notepad, for instance. Remember, though, that the changes will impact only the system where the Hosts file is located.
3] Where Is a Hosts File Located?
Each operating system has a unique host file location. Given below is the location of the Hosts file on a Windows 10 or 11 PC:
Local Disk (C:) > Windows > System32 > drivers > etc > hosts
4] How to Edit a Hosts File
For Windows, there are two options to edit a Hosts file: manually or with the Hosts File Editor tool such as PowerToys. The instructions below are widely applicable to all Windows versions.
Edit the Hosts File Manually
- On the Windows search bar, type notepad, right-click on the result, and select Run as administrator.
- Press Yes on the User Account Control prompt.
- Click on the File tab and choose Open from the context menu. Next, navigate to this location This PC > Local Disk (C:) > Windows > System32 > drivers > ETC
Note: Click on All Files from the drop-down menu to make the hosts file visible.
- Select the hosts file and then click on the Open button.
- You can now edit the Hosts file. Enter the appropriate IP address and hostname at the end of your Hosts file, click Save, and then close the file.
Using PowerToys
PowerToys is a more straightforward way to edit the Hosts file in Windows. If you don’t have it installed, follow the link, and download it based on your PC configuration. The setup is available for ARM and 64-Bit PCs.
Once installed, launch the software, and click on Hosts File Exitor listed in the left section. Toggle the Enable Hosts File Editor to start working with it.
Create a new entry
Click on Launch Host File Editor, and it will reveal the list of all the available entries on the file. A toggle button is next to it, and you can enable or disable it.
To add a new entry, click on the New entry button, and it will reveal a pop-up window where you can add an IP address, HOSTS, Commentr, and if you want to activate it right away. Click on Add button to make an entry in the file. It will be instantly saved.
Hosts can be a website address available to the public or hosted on your computer.
Filter entries in host files
You can use the filter to find the entry if you have too many entries in the Hosts file. Click on the filter icon, then type characters in the Address, Hosts, or Comment fields to limit the range of results when filtering host file entries.
Hosts backups of files
Before beginning an editing session, the PowreToys makes a backup of the hosts file. The backup files are located nearby the hosts file at %SystemRoot%/System32/drivers/etc
and named as hosts_PowerToysBackup_YYYYMMDDHHMMSS
Settings
The following settings can be set up from the Settings menu:
- Launch as administrator: Run the program as administrator to edit the hosts file. The editor is launched in read-only mode if disabled. By default, the Hosts File Editor is launched as administrator.
- Show a warning at startup: Warns that changing hosts can alter how DNS names are resolved. The warning is, by default, turned on.
- Additional lines position: If the Bottom is chosen, hosts settings are relocated before file headers and to the bottom. The Top is the default value.
Troubleshooting
A Failed to save hosts file message is displayed if a modification is done without administrator access. To fix the problem, enable the Launch as Administrator option in settings.
Conclusion
So, I hope you understand what a Hosts file is, why to modify it, its location, and how to edit it. Also, remember that these changes only apply to the computer where the Hosts file is located and require administrative permissions on each system. You can also use the Hosts file editor tool to edit the Hosts file.