A HOSTS file is used to manually force map a hostname to an IP address without relying on a DNS service. The HOSTS file is found on every operating system and for Windows, it is located at Windows\System32\drivers\etc\ folder, just with the filename as HOSTS without an extension. By default the HOSTS file doesn’t contain any mappings and most computer users don’t even need to touch the file. The below image is how the default Windows HOSTS file looks like.

However, web developers who are developing websites locally from their computer may find it useful because they can download the whole website’s code to their computer, map the domain name to their computer’s IP address and immediately start editing without worrying about the absolute URLs. Another common usage of HOSTS file is to block websites including advertisements and web trackings by mapping it to a localhost which is 127.0.0.1 or to a non-routable 0.0.0.0 IP address. Other than using the HOSTS file for good purposes, some malware uses it to block the infected computers from accessing security based websites.
There are times when you need to check the HOSTS file, for example when you suddenly find a website inaccessible from a particular computer while it loads perfectly fine on others. Here is how to view and edit the HOSTS file in Windows.
(more…)







