April 4, 2015

Edit/Add to hosts file in Windows

On Mac or Linux, this is a cinch.
sudo vi /etc/hosts

On Windows, it sucks, and you will probably run into the "You cannot modify the Hosts file" error. Here's the workaround.

Navigate to Start Menu -> All Programs -> Accessories and right-click Notepad to run it as an administrator. You may be asked for your password at this point:

Navigate to the hosts file in Windows Explorer. It is located at C:\Windows\System32\drivers\etc\hosts. Right click it, and un-select the Read-Only attribute:

Now use Notepad to navigate to the hosts file. Be sure to view All Files!


Finally, change what you need to change. When done, do not just click File -> Save, but instead do File -> Save As... and overwrite the hosts file. You may again need to specify All Files as done above, else the hosts file you modified will just be saved as a .txt copy, which does nobody any good. Lastly, after saving, remember to make the hosts file Read-Only again.

No comments :

Post a Comment