While working through an issue I learned how to edit my Windows machines hosts file. Its easy enough to do provided you know how to do it. The resources on the Internet that I came across all had bits and pieces of the puzzle. Here I’m documenting them all in one place for the next time I need to do this.
First, lets open notepad with administrator privileges. At your Windows START menu type the word “notepad”. Look for the application icon, right-click it, and choose “Run as administrator”. Notepad will launch.
Next, click “File” then “Open” and type/paste the following path:
For “File name” enter the word “hosts” without a file extension, then click “Open”.
Your hosts file will open. It already contains a description of how to use it so I wont go over that part. What I will go over is **how** to save the file. If you simply do CTRL+S or “File > Save” you have created a “hosts.txt” file NOT a “hosts” file. Therefore, your edits will have no effect.
To PROPERLY save the file, do the following:
- Click “File”
- Click “Save as…”
- File name should be the word “hosts” with no file extension
- “Encoding” should be “ANSI”
- Click “Save”
Next you may need to clear your local DNS cache, to do so start a command prompt (In the START menu type “cmd” then hit ENTER) then type the following:
- ipconfig /flushdns
Hit enter to execute the command and you will receive a message that the DNS Resolver Cache has been flushed.
To verify your edit worked try browsing to the host that you had setup.