How to Edit Hosts File in Windows 7, 8 and 10?
Hosts file is a local file available as part of an operating system and used to map IP addresses corresponding to domain names. The browser then resolves the entered domain name into an IP address found in the hosts file before using browser’s DNS settings. There are two major need for users to modify hosts file.
- Eliminate the resolving host time through normal DNS resolution.
- Block certain domains by pointing it to local host IP address.
In both cases you need to create additional entries in hosts file and this article explains how to edit hosts file in Windows 8 and 8.1 operating systems. The procedure remains same for both in Windows 8 and 8.1.
Step1 – Open Notepad in Administrator Mode
Click on the “Start” button located at lower left corner.
Right click on “Notepad” app and click on “Run as administrator” option.
Step2 – Opening Hosts File
Once Notepad is opened in administrator mode click on “File > Open” from the menu.
Hosts file in Windows 8 is stored in the location “C:/Windows/System32/drivers/etc/”. Go to this path and open the hosts file in Notepad.
Step3 – Modifying Hosts File in Windows 8
Add required entries in the hosts file and save the file.
Basics Rules in Modifying Hosts File:
- Though tab is used to separate IP and domain, a single space is sufficient between IP and domain name.
- Add each set of IP and domain in a separate line.
- Add domain and subdomains separately. For example, webnots.com, webnots.com and blog.webnots.com needs to be added as three separate lines though IP address could be same or different.
- Use # to add comments in the hosts file.
- Hosts file does not have any extensions, hence ensure to save the file as “All Files” type and not as a text document with .txt extension.
- Once hosts file is changed, restart the computer for the changes to take effect.
Step4 – Blocking Sites Using Hosts File
Besides resolving the host name, hosts file can also be used to block sites by pointing the domain to the localhost IP address. For example, add the following entry to block facebook.com from your computer:
Here, 127.0.0.1 is the IP address of the localhost for IPv4, in case of IPv6 it should be ::1.