Can't Edit hosts file in Windows 10

thebest8
thebest8 used Ask the Experts™
on
Hello,

I was trying to add a line in hosts file to adjust a domain name with wamp server but it doesn't allow me to, I get access denied and another error: The process cannot access the file because it is being used by another process...

I tried many ways through this link http://windowsreport.com/access-denied-hosts-windows-10/

But still doesn't work. I have Avira Antivirus and ZoneAlarm firewall all disabled and still something is missing
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Hi,
right click on "../etc" folder where the hosts file reside

add permission in properties/security for your account: give full control.

It will work ...

hope this helps
max
systechSenior Technical Lead
Commented:
Hi,

Make sure that you have full control of the file/folder (or administrators group and you are member of that group). The second error you mentioned looks like some of the services still using the file. I.e - "DNS client", "TCP/IP NetBIOS Helper" services etc.
Distinguished Expert 2018
Commented:
Before editing, start notepad elevated: right click notepad.exe and select "run as administrator" - now it will work.
Build an E-Commerce Site with Angular 5

Learn how to build an E-Commerce site with Angular 5, a JavaScript framework used by developers to build web, desktop, and mobile applications.

Business Consultant (Owner)
Most Valuable Expert 2012
Expert of the Year 2018
Commented:
Open Notepad using Run as Administrator. Navigate to the HOSTS file, open it, edit it and save it.

I do this instead of giving full control to the HOSTS folder.  Providing full control to this folder (target for viruses) reduces security.
Abhi PappiTechnical Lead - Network Support
Commented:
Hi,

Open a command prompt with "run as administrator", and run the command

notepad c:\windows\system32\drivers\etc\hosts

Is it opening?

Thanks,
Distinguished Expert 2017
Commented:
To add to what was already said since Windows 7 even administrators starting programs, those program run with limited rights unless run as administrator was used to start them, as covered by the experts earlier. With that said, notepad is not UAC aware or uac notifications are disabled. In either case when one tries to save and elevation is needed, the user will not be prompted.
Using netepad+ or othe similar text editor...

In the absence, I be would save as in another location, and then use file explorer to copy the modified hosts file to the c:\windows\system32\drivers\etc

Author

Commented:
Still didn't fix it, I have attached several screenshot for you to check, it doesn't work with Run as Administrator
cap1.JPG
cap2.JPG
cap3.JPG
cap4.JPG
Cap5.JPG
Cap6.JPG
Distinguished Expert 2017

Commented:
what are you running as administrator?
try the suggested solution, save a copy of the modified hosts file. then copy it using file explorer and once prompted provide admin credentials and you should be done.

What happens after you click the OK to elevate your rights in cat6.jpg?
JohnBusiness Consultant (Owner)
Most Valuable Expert 2012
Expert of the Year 2018

Commented:
The attributes on the file are correct. Let's cover the instructions again.

Right Click on Notepad.exe and select Run as Administrator. Does this work?  Are you challenged for credentials?  if so, then authorize. Make this entire step is completed.

Now inside Notepad, navigate to HOSTS and open it. There is more than one HOSTS file - make sure you select the active one.

Now edit and save.
Distinguished Expert 2018

Commented:
cap3.jpg shows, that some other process has locked this file (which is not normal). Do you have that hosts file open in anything else but notepad at the same time? If in doubt, logoff and on again and repeat what you just did.

Author

Commented:
Ok I found the solution to it.

The issue is coming from ZoneAlarm and Avira Antivirus locking hosts file

check screenshot
cap7.JPG
cap8.JPG
JohnBusiness Consultant (Owner)
Most Valuable Expert 2012
Expert of the Year 2018

Commented:
Avira has caused more than one problem in here. Safety by preventing people from working.

Author

Commented:
thank you all
JohnBusiness Consultant (Owner)
Most Valuable Expert 2012
Expert of the Year 2018

Commented:
You are very welcome and thank for your helpful update. I was happy to work with you on this.

Author

Commented:
thank you Mr John

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial