15 Troubleshooting Tips for Windows Hosts File. Make It Work Again.

Hosts file

The Hosts file is one of those tools that are never listed on the best or the most useful Windows apps, software, or hacks just because it’s a file. It’s just a file, alright, but what a wonderful file it is. It’s every Windows user’s own little Domain Name System.

The Hosts file can be configured to provide you with a number of benefits. It works almost every time but there can be those times when it fails, and refuses to map the IP addresses to the domain names listed in it. Here are a few troubleshooting tips that can help you make it work again.

15 Troubleshooting Tips for the Windows Hosts file

1. File Type

The Hosts file is not a text file, it’s just a file. By default, the file extensions are hidden in Windows. A user can accidentally save the Hosts file as a .txt (Text) file, and not see the file extension as they are turned off.

2. Syntax Errors

Follow the correct syntax. Type the name of the IP address, then a tab or one space, and then the domain name. Use only one tab or single space between the IP addresses and the domain names. Try to follow only one option, either tab or space in the entire Hosts file.

3. Comment Markers

Make sure you have not placed the comment marker (#) at the beginning of each entry in the Hosts file. The comment marker nullifies the code after it in that line.

4. WWW and Non-WWW

Write the www and the non-www versions of the domain name that you want to block. This will block the main domain as well as all of the subdomains connected to the main domain.

5. Encoding Errors

Use only the ANSI or the UTF-8 encoding type to save the Hosts file.

6. Permissions Problems

There may be a problem with the current hosts file. Create a new file in notepad, copy paste the contents from the original file, save it without any file extension, and move it to the directory of the Hosts file. Delete the old file.

7. Start From Scratch

If the new file with copied and pasted material also doesn’t work, then create a new file from scratch removing all of the previous entries. Start typing the entries again in this new file, once you have created the complete list, move it to the directory of the Hosts file. Delete the old file.

8. Command Prompt Commands

After editing the Hosts file, don’t forget to run the ipconfig /flushdns command in the Command Prompt to clear the old DNS Cache. The changes made in the Hosts file should take place immediately, however, you should still delete the old DNS Cache stored in Windows.

9. Don’t Use Automatic Configuration Script

Clear the Use automatic configuration script checkbox in the Local Area Network (LAN) Settings window under the Internet Properties. When enabled, this option overrides the Hosts file.

10. Reset TCP/IP Settings

Go to the Adapter settings. Reset the TCP/IP settings by clearing the TCP/IP v4 and v6 check boxes, and then ticking them again. Try disabling the v6 option to see if Hosts file works or not.

11. File Security

Clear the Read-only checkbox before in the Hosts file Properties window before editing the Hosts file. Make the file Read-only again after editing the file. If it not Read-only, then it becomes easier for the malware to alter it.

12. Wildcard Doesn’t Work in the Hosts file

Typing and saving *.example.com does not block all of the subdomains of example.com. You have to specify every subdomain in the Hosts file.

13. Check Windows Registry Path

The correct path to the Hosts file is mentioned in the following Registry Key.

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters

Under this Registry Key, check the Registry String called DataBasePath. Its value data should be the correct location of the Hosts file, which is:

%SystemRoot%\System32\drivers\etc

14. File Name

The Hosts file is just “hosts”. It is not Host, h0st, ho$t, etc. Make sure the filename is correct.

15. Malware Attack

The last troubleshooting tip that would like to mention is actually very simple, and not directly related to the Hosts file. There are some malware that can alter the Windows DLL file (dnsapi.dll) that maps to the Hosts file, and make Windows point to a different Hosts file that they created. So, in that case, even if everything was right with your Hosts file, the domain mapping done on it will not take place because that Hosts file is not being used at all. Scan your computer with your up-to-date Antivirus, and a second-opinion malware-scanner.

One of these should definitely fix your Hosts file. Good luck!

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.