Can't Edit hosts file in Windows 10


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

But still doesn't work. I have Avira Antivirus and ZoneAlarm firewall all disabled and still something is missing
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
Radhakrishnan RSenior Technical LeadCommented:

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.
Before editing, start notepad elevated: right click notepad.exe and select "run as administrator" - now it will work.
Acronis True Image 2019 just released!

Create a reliable backup. Make sure you always have dependable copies of your data so you can restore your entire system or individual files.

JohnBusiness Consultant (Owner)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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Abhilash PappiyilTechnical Lead - Network SupportCommented:

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

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

Is it opening?

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
thebest8Author Commented:
Still didn't fix it, I have attached several screenshot for you to check, it doesn't work with Run as Administrator
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)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.
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.
thebest8Author Commented:
Ok I found the solution to it.

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

check screenshot
JohnBusiness Consultant (Owner)Commented:
Avira has caused more than one problem in here. Safety by preventing people from working.
thebest8Author Commented:
thank you all
JohnBusiness Consultant (Owner)Commented:
You are very welcome and thank for your helpful update. I was happy to work with you on this.
thebest8Author Commented:
thank you Mr John
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows 10

From novice to tech pro — start learning today.