not able to edit hosts file in windows

In this guide, we will learn about how to edit Windows hosts file with simple click and edit. As it is internal system file the Microsoft Windows 10 or any version will not let you edit it. So, I will share the step-by-step guide on how to edit the hosts file in Windows 10 that also works on all other windows 7 and 8 too.

What is Windows hosts file and where to find it?

What is Windows hosts file

A windows hosts file is an operating systems file that maps hosts with their respective IP addresses. It is plain hosts file that doesn’t have any type or a simple file.

Windows 10 hosts file location

In all modern Windows operating systems, the hosts file is present at the same location. By modern we mean Window 7/8/8.1/10 for now. This file exists at C:\Windows\System32\Drivers\etc.

How to edit hosts file in Windows 10

At some point, you have to edit the hosts file. Before making any change, I will recommend you to create a backup copy of it and save it somewhere else safe so in case of any issue you can restore it back. Now, right-click on the hosts file and click open with Notepad.

Why edit hosts file in Windows 7,8,10 –

Consider hosts file as a redirector, means it lets you change the host of some certain domain to something else. That’s too much of technicality. Let’s understand this with an example.

You browse/access facebook.com (called domain name). There is a certain number associated with each domain names to figure out which servers to land on called IP Addresses like 192.168.0.1. Now, once you type facebook.com it maps with the facebook’s IP address and it takes you to that server.

Now, assume you want to redirect a user when they search facebook.com from your browser to google.com. What you need to do is write a rule in the hosts file. So, whenever a user runs facebook.com from a browser, he will always be redirected to google.com.

Let’s understand the structure of the hosts file –

Once you open the hosts file in notepad. You will see a lot of text with a lot of hashtags. It’s okay to be confused as everything is coded and everything it has a meaning.

How to edit Windows hosts file in windows 10 techcrook.com
Default hosts file

The hashtag there represents one-line comments. Comments are there to instruct you how to edit the file and the comments are just for that. They don’t add any relevance to the host.

How to change or edit hosts file –

Now, let us assume you want to redirect yourself whenever you search facebook.com to google.com. What you need to do is add a new rule which includes IP address of the website you wanted the user to get redirected to and the website on which redirection took place. In our case, we need the IP address of google.com and redirection will take place whenever our user searches for facebook.com.

The IP address of website changes from time to time so first you need to find the IP address of the website you want them to redirect to. Here is an article explaining how to find the IP address of any website using simple cmd commands. Follow the mentioned guide and get the IP address of a website you want them to redirected to.

Add 216.58.221.46 facebook.com at the end of the file. The left represents the redirected website’s IP address in our case Google’s while the right side must have the domain that needs to be redirected.

To edit/save the changes in hosts file –

Now to save the file what you need to do is, click on File >> Save as. Don’t change the name of the file but make sure to change the save as type to All before saving. Now go to the desktop, you will see the file is saved as hosts.txt. If you can’t see the .txt then it is possible that you have to not enabled file name extension from Folder options. Here is a guide how to enable file name extensions in Windows 8/10.

Once you can see the file name hosts.txt, right-click on it and rename it by deleting .txt at the end. The file name should be now hosts only and its properties should look something like the image below. Now copy this file (hosts) from desktop and paste it to its original position that is C:\Windows\System32\Drivers\etc.

In any case if you want to reset file back to default you can follow this thread on Microsoft support.

Make sure the type of file must be File before pasting to its original location

Conclusion:

You understand how we can edit/change the hosts file. I also mentioned the internal structure of the file and we also discussed how we redirected facebook.com to google.com using hosts file.

Let me know if you get any issues while editing your hosts file. Comment it down here and I will try to resolve any issues that you have.

Do you know something interesting? Submit your story here. Want to know something else? Ask for an article here.

Buy Chobby NTO

Mint a Chobby at $250: Get 1000 $CHO($910), $600,000 in Raffle, 5% royality future sales