My host file is not working on Windows 10

Solution 1:

Just changing the hosts file is not enough. You also need to flush your DNS cache.

Open a command prompt and type:

ipconfig /flushdns

Now, test if it works by pinging one of the domains, preferably one you changed recently:

ping www.website2.com

and see if it returns the 127.0.0.1

If the ping does not work, then it is likely that the permissions on the hostfile are incorrect. Incorrect permissions on the hostfile may cause an arbitrary lock on the hostsfile which prevents windows from properly read it and populating the dns cache. Fix the permissions on the hostfile then perform an ipconfig /flushdns once more.

If the ping works, but the website does not load correctly, then the website is still loading from cache. Clear your browsercache to fix the issue.