How to Use the “Hosts” File?
Have you ever thought about how you get connected to a website? What makes the system so unique that lets you land on the website without ever getting you on the wrong one?
Well, the answer lies in the IP address! Every website has a unique IP address just like our mobile numbers. Every time we dial a number, we get connected to one individual.
But how many mobile numbers do you remember actually? Probably 10 at maximum! Then how do you remember all those mobile numbers? You save them, right? You designate each number with the individual name and look for that number in the contact list and here you go!
Domain names are easy to remember in comparison to IP addresses. This is exactly what the DNS server does. It searches for the domain name you entered with its IP address in the server and lets you access the website.
But do you know, you can replicate the same process through hosts file with added benefits? The host file resolves domain names locally on your computer, without querying DNS.
Today, we will learn about hosts file and how you can access the Host File!
What is a Host File?
A hosts file is a text file used by operating systems to relate the domain names to IP addresses. It serves as a local DNS resolver that allows your computer to translate domain names to IP addresses without making a query into a DNS server.
How Hosts File Benefits You?
There are multiple benefits of using the hosts file. Some of them are listed below-
- Testing: It is a good way to test the website. You may redirect domain names to different IP addresses for development.
- Blocking Access: There may be a few websites that you might want to block. So you can prevent access to certain websites by mapping them to a non-routable IP address (like 127.0.0.1).
- Speeding Up Connections: Last but not least, you can reduce DNS lookup time for frequently accessed sites upto a great extent.
Accessing Hosts File in Windows 8 and 10
Step 1: Search Notepad
Search for the Notepad in the search bar at the bottom of the window screen.
Step 2: Run Notepad as Administrator
- The Notepad icon will be displayed on the right side of the screen. It will also appear on the left side of the screen under the command section.
- Now you have to click on the drop-down button beside the Open button under the Notepad icon on the right side of the screen. Alternatively, you can click on the drop-right button on the left side of the screen, beside the notepad under the command section.
- In both cases, you will get the option of Run as administrator. Click on that option.
Step 3: Opening the Host File on Notepad
- Toggle on the local drive C and then open the Window
- From there select the system 32 folder (for your reference, the path has been shown on the screenshot)
- From system 32 folder, select the drivers folder.
- Select the etc folder within the drivers folder.
- Once you open the etc folder, you will get the host file you want to access. It might happen that you may see No items match your search. This is because Text documents (*.txt) is selected by default in the drop-down menu next to the File Name search box.
- In this case, you just need to select the All Files by clicking in the drop-down button.
2. Now you will be able to see hosts file on the top of the list of files.
3. Click on the hosts file and it will show you the entire content. You can add your entries after the last entry and then click on File > Save to save the required changes.
Note: Use the following keys-
- Tab key to space the IP address and the domain name
- Enter key to begin a new entry.
How to Disable an Entry in Hosts File?
If you have made an entry but do not want to delete it, rather you just want to disable that particular entry, you can do so by the following two methods:
- Put the hashtag sign “#” before the line, for example:
# 157.240.229.35 facebook.com
2.Use website address designations like “/” or http://.
These are the two ways you can disable the entries in the host file while keeping them for future reference.
Final Words
Now that you have learned how to access the host file, you can make the required changes to resolve the domain names locally.