Uh-oh! Could not update hosts file | Unable to Grant Admin Permission

Issue Summary

Local requests permission to edit the host file, but clicking on the notification in Windows 10 does not grant the permission. I’ve seen a lot of other posts with this issue, but no solution other than switching routing mode from site domains

Of course, the error that pops up says

"Uh-oh! Could not update hosts file

Local ran into a problem when trying to update the hosts file

Please ensure that the hosts file is not locked by anti-viurs"

Following the advice in this post: Help! I'm running into an EPERM error with the hosts file on Windows

I’ve disabled Windows security, I don’t have another AV installed. I double checked that the hosts file itself is not read only.

Troubleshooting Questions

  • Does this happen for all sites in Local, or just one in particular? All Sites

  • Are you able to create a new, plain WordPress site in Local and access it in a Browser? No

System Details

  • Which version of Local is being used? 6.1.4+5521

  • What Operating System (OS) and OS version is being used? Windows 10 Pro

Log File!

local-lightning.log (303.8 KB)

I do see a few errors along with a warning that seems interesting:

{"thread":"main","level":"warn","message":"Could not retrieve Windows edition.","timestamp":"2021-10-14T16:29:47.503Z"}
...
{"thread":"main","class":"HostsFileService","error":{},"stdout":{},"stderr":{},"exitCode":{},"level":"error","message":"Could not update hosts.","timestamp":"2021-10-14T16:29:53.115Z"}

You’re on the right track in terms of examining Antivirus as well as permissions on that file.

The reason that I brought up the warning of

Could not retrieve Windows edition.

is because I’ve seen this message for some users under Windows Pro. Is this computer a work computer? Along those lines, is there any sort of security settings in place by the IT department?

No, it is a personal computer. There shouldn’t be any security restrictions that I am aware of. Are you able to provide any more info about this error?

I don’t have any more info than that since our team doesn’t have a Windows Pro machine to replicate on.

One possible test you might try is if the permissions on your user account are more restrictive for some reason. I wonder if you created another user on the machine, and installed under that user, if there would be any different behavior?

Don’t mean to ask a stupid Q, but did you check the folder that the host file is in is not read only, and not just the hosts file inside the folder? That was one of the things that was the prob’ with mine.

1 Like

Hi Ben,

Yes, I did try creating another admin account and the same error persisted. I am also running into the same issue on another machine running Windows 10 Home.

On both machines I am also unable to trust the SSL certificate since Local is not able to access admin permissions.

If Local is unable to edit the hosts file and you can’t zero in exactly on why that’s the case, then the only other option would be to run Local in the localhost Router Mode.

You can change that setting by navigating to the “Preferences > Advanced > Router Mode” page.

For more info, see this help doc:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.