To be able to edit the hosts file in windows follow these steps:

  1. File location is: C:\Windows\System32\drivers\etc
  2. Open with Visual Code Text Editor
  3. Make your changes and save
  4. You will get a prompt, select 'Retry as Admin...'
  5. Select Yes to save
  6. Flush you DNS with this MS-DOS terminal command: ipconfig /flushdns

 

Recently ran into a situation where we needed to modify the hosts file in a windows machine. Our first option was to use notepad.exe as the text editor.

You can find the hosts files at: C:\Windows\System32\drivers\etc

When you open it and save the changes, you are prompted by the following:

Save As
C:\Windows\System32\drivers\etc\hosts.txt
You don't have permissions to save in this location.
Contact the administrator ot obtain permission.

Would you like to save in the Documents folder instead?