Sometimes, troubleshooting malware and unwanted software involve making some changes in hosts file. This simple file is responsible for mapping hosts to IP-addresses. Changing hosts file in Windows 10 may result in inability to open specified websites or apps, thus it is good to know hosts file path in Windows 10, and how to edit it in case of emergency.
We assume you have a solid reason to edit hosts file in Windows so we won’t describe scenarios in which editing hosts file may come in handy. And yes, do not edit hosts file for no reason. Just like with other Windows settings, abusive changes may make your PC unstable and unusable.
Hosts File Location in Windows 10
Hosts file located in C:\Windows\system32\drivers\etc. This path is the same for every recent Windows version. Etc folder usually contains five different files with no extension. One of these files called hosts. That is the one. Don’t mind the fact that it has no visible extension. There won’t be any even with file name extension option being checked. In reality, hosts file is a simple txt file which makes it very easy to edit or create in case it is missing.
Here is a tip: etc folder may contain few hosts files. That is totally fine. In order to edit the correct one, we recommend enabling file name extensions option. Click on View tab and check File name extensions option. In addition, use Type column as a reference. Hosts file has simple “File” type in there. It shouldn’t be “Text file”, “txt”, etc.
How to Edit Hosts File in Windows 10?
Let’s move to editing hosts file in Windows. Again, this procedure is the same for all recent Windows version whether it is 10, 8.X or 7. The only difference between them is how you launch Notepad. Although it may sound weird, you need to properly run Notepad before editing hosts file in Windows. If you don’t, changes won’t be saved. Long story short, you need to run Notepad as Administrator.
- Press Win + S and type in Notepad. Click Run as Administrator.
- Now copy the following path: C:\Windows\system32\drivers\etc.
- Return to Notepad and click File – Open.
- Click on the address bar and paste the path you copied before. Now you are in etc folder
- You won’t see any files in there. That is totally ok because by default Notepad is looking for txt file. As you already know, hosts file has no visible extension, thus it does not show up in the Open window.
- In the bottom part of Open window press on Text Documents (*.txt) and select All files from the drop-down list. Now you can click on hosts file to open and edit it.
Now you are all set. Make any changes you need then click File – Save (Ctrl + S) and close Notepad.
File Hosts is Empty or Missing
Let’s debunk some fears regarding hosts file in Windows 10. If hosts file is blank and has nothing inside itself, don’t worry. That is totally fine. By default, hosts file is empty even if it has some visible text (like on the screenshot below). Note that every line begins with # symbol. This symbol is used to insert comments just for the reference or convenience. System ignores everything after the # symbol. In other words, hosts file may be completely blank, and everything will be fine.
If you want to make some changes, make sure not to begin a new line with # symbol. For example, if you want to redirect domain.com to localhost—which is 127.0.0.1 on every Windows machine—you should go to the new line and type in the following:
Make sure to have at least one space between IP and host, otherwise it won’t work. If you want to place some text for future reference, place # anywhere and type in something after it in the same line:
127.0.0.1 domain.com # reference text
What to do if hosts file is missing? Don’t panic. Missing hosts file is fine. Windows can operate normally even without host file. After all, it is empty by default, thus makes no difference. If you need to edit hosts file in Windows 10 and there is no such file, simply create it.
Go to desktop and right click any blank space. Select New – Text Document. Rename it to hosts and delete file extension (.txt). Windows will tell you that this action may make the file unusable. Ignore that message and press Yes.
Copy the file and paste it in C:\Windows\system32\driver\etc. Now open it and make any changes you want. Just make sure to run Notepad as Administrator before you edit hosts file in Windows.