“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 antivirus.”
I have confirmed the hosts file is editable manually without issue, and no antivirus software is installed or active.
What steps can be taken to replicate the issue? Feel free to include screenshots, videos, etc.
Open LocalWP.
Attempt to create or activate a new local site.
The error immediately appears about failing to modify the hosts file.
Explicitly setting file ownership of the hosts file to my user account with Full Control permissions.
Completely uninstalling antivirus software and temporarily disabling Windows Defender real-time protection.
Verifying via Resource Monitor that no other processes lock the hosts file.
Resetting LocalWP’s configuration and reinstalling LocalWP entirely.
Edit Hosts file directly without issue
Set to localrouter
Despite these actions, the issue persists.
Screenshot examples are attached.
System Details
Local Version: Version 9.2.2+6771
Operating System (OS) and OS version: Edition Windows 11 Pro
Version 24H2
Installed on 4/1/2024
OS build 26100.3323
Experience Windows Feature Experience Pack 1000.26100.54.0
With all the steps you’ve taken so far can you now try a full uninstall and reinstall of Local?
Export any sites that you have on Local and save them to a folder somewhere on your computer: Backup a Local Site - Local
Fully uninstall Local from your computer with the Windows specific steps here: Uninstall Local - Local
Install the latest version of Local on this link: Releases - Local
Once installed, please restart the computer.
When the computer is restarted and turned on, close any applications that automatically run in the background (AntiVirus, Firewall, and other Developer applications included).
Do you have many sites in Local? You can go into the Local Sites folder to grab all of the site files at once and save them instead of exporting them one at a time.
Before you get started - Is this a personal device or one issued by your employer? If it’s not a personal device, it might have some extra security or permissions that an IT person can help with.
Otherwise, it seems like you’ve done all of the other checks here, but if you don’t want to go through the trouble of exporting/importing everything, it can’t hurt to double-check it all one more time.
Hi again! Not good news I am afraid. After spending an awfully long time of exporting, then deleting, then uninstalling, then rebooting and reinstalling, same exact issue.
Could you share one more fresh log with us @dikdronk? Please click the Download Local Logs button from the Support tab in Local. This will generate a zip archive that contains the Local log along with some other diagnostic information to help us.
If you do not see that at any point when creating new sites, you might be running into the same issue as the Local user from the thread linked below. They ended up resolving it by correcting some broken PATH variables on their machine. Click through for their helpful guide with screenshots, just in case you haven’t seen or tried that yet: