Help! I'm running into an EPERM error with the hosts file on Windows

This is usually caused by the hosts file being set to read-only or locked by anti-virus.


1. Remove Read-only Attribute

  1. Go to C:\Windows\System32\drivers\etc
  2. Right-click on the hosts file and go to “Properties”
  3. Uncheck “Read-only”
  4. Click “Apply”
  5. Re-open Local

Screenshot


2. Anti-Virus/Internet Security

Avira

See https://answers.avira.com/en/question/avira-blocks-hosts-file-what-can-i-do-90

Kaspersky Total Security

  1. Open Kaspsersky Total Security
  2. Go to “More Tools”

  1. Go to “Application Control » Details”

  1. Click “Manage applications”

  1. Right-click on “Local by Flywheel” and set its Restrictions to Trusted


If the steps above do not work, you can try adding the Window’s hosts file to the exclusions list in Kaspersky to resolve this issue. See https://support.kaspersky.com/12160 for details on how to add an exclusion.

Once you have the exclusion window open, exclude this path: C:\Windows\System32\drivers\etc\hosts