Link to home
Start Free TrialLog in
Avatar of Colin Brazier
Colin BrazierFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Cannot save edited hosts file

Hi experts,

I am trying to edit my hosts file C:\Windows\System32\drivers\etc\hosts  but it won't let me save it and tells me it is being used by another program.  I have no other apps open, and apache is stopped.

When I try to delete the file (I have a copy waiting) I am told that the file is being used by system.

Any ideas on how I can edit and save the file please?

Cheers
Avatar of Nitin Sontakke
Nitin Sontakke
Flag of India image

Try coping it somewhere else (such as desktop), edit it and then paste it back at its location.
Get UnLocker (https://www.iobit.com/en/iobit-unlocker.php) to see who are using the file. It's no usual that HOSTS file are open and locked by system. Eventually, unlock it. Edit the file with something that are running with high level privilege .
Avatar of ☠ MASQ ☠
☠ MASQ ☠

Hosts is a protected system file, make sure if you're editing you open the editor program of your choice as admin with elevated privileges (right-click "run as admin").
It's a virus try to use Microsoft Essential to solve this issue or any strong malware
It can be that you need to be admin to edit it or your Anti Virus is locking it down. When I used WebRoot the file was locked down. So I would check there also if none of the other suggestions worked. All I did was shut Antivirus down for a short time till I edited the file.
Avatar of Colin Brazier

ASKER

Thanks for the responses.
Try coping it somewhere else (such as desktop), edit it and then paste it back at its location.
Same problem, copied as administrator.

Hosts is a protected system file, make sure if you're editing you open the editor program of your choice as admin with elevated privileges (right-click "run as admin").
I used Notepad++ as admin.

I doubt it's a virus, I run Malwarebytes fairly often and nothing is found.  Running it again now.

Could be the anti-virus program though, I'll shut it down and re-try.
I used Webroot for a while and I had the same issue. Webroot protects that file so a virus cannot make changes to it.
May also be malware protection software as lots of nasties try to write to hosts. Normally they should notify you of the attempt to edit hosts and get your permission though.
Nope, stopping antivirus/firewall doesn't help.   Malwarebytes found nothing.

Sheesh!
SOLUTION
Avatar of Edward Pamias
Edward Pamias
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Just right click on the host file and go to properties, and uncheck Read-only if its checked.
I have Windows Defender, always disabled, and ZoneAlarm Extreme Security.

The file is not read only, but the folder "etc" was/is, so I changed that, seemed successful, but when I went in to look again it was read only!

I installed and tried Unlocker, that reported a successful unlock, but I still couldn't edit and save it.  I went in again via Unlocker and it showed it Locked.

I don't really want to use the Force option in Unlocker.
I just looked up another solution. Since you are using Zone Alarm, you will need to boot to safe mode to edit the file. Try that and let me know if that helps you.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks - that was it...

With ZA hosts is locked at Firewall/Basic Firewall/Settings/Advanced Settings

I really appreciate all your time on this guys.
Thanks again guys.