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-virus

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-virus.

I disabled the read-only file format

But the problem did not disappear. what is the problem?
Even the PATH thought to change it in the system settings

Hi @agentdmitro

We would be happy to assist with your Local troubleshooting! Could you provide some more details to help us take a further look?

  • What is your OS?

  • What version of Local are you on?

  • Please attach a copy of your Local Logs

Keep us posted and we’d be happy to help further!

Hi

  1. My OS is Windows 10 for 1 lang.
  2. Local Version is 6.7.2+6375

local-logs.zip (58.8 KB)

Hi @agentdmitro

Do you have any antivirus, security, or firewall applications that could be blocking Local?

More details about troubleshooting this here: Router Mode

Are you running other developer applications simultaneously? That could also cause similar issues. Apps like MAMP, XAMPP, or Docker for example.

No, i don`t

Hi @agentdmitro

Has the issue persisted for the last 3+ weeks since you created your post? Or have you been able to find a workaround?

Since it’s been awhile could you share an updated Local Log if you’re still having trouble? Retrieving Local’s Log File

I have not used the program for this period of time.
The workaround is to directly make changes in the file and insert the ip like all the others. and add a site name
When I start the server, the error pops up again, but the site works. Of course, it is not as convenient as we would like.

The log file has not changed.

I’m glad you have found a workaround at least.

Have you tried a full uninstall/reinstall of Local? If not, and you want to test you could run through the steps here:

  • Export any sites that you have on Local and save them to a folder somewhere on your computer.

  • Fully uninstall Local from your computer.

  • Install the latest version of Local on this link.

  • 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).

  • Check and see if the issue still persists. If so, please provide us with an updated log. Retrieving Local’s Log File

Keep us posted and we’d be happy to help further!

local-logs1.zip (59.1 KB)
Nothing has changed, the problem is the same.
I did everything as you said

I’m not sure what else on your machine could still be blocking things here if you’re unable to uncover anything else. Do you have another machine by chance you can test Local on to see if it works normally?

I have never installed any antivirus. only standard from Windows 10
Maybe it happened after I changed the path in system settings?

I even excluded LocalWP from antivirus scans

What did you change the path to in those settings? Did you try reverting that?

Hello,
after some troubleshooting and being frustrated, I got it.

Solution 1 -
Somehow my HOSTS file got read only, and after removing the read only status it worked normally.

To do that go to
C:\Windows\System32\drivers\etc
then right click on hosts file and go to properties and under general tab uncheck the read only option and click OK, thats it.
(you have to have administrative privileges)

Now More technical solution… i.e. Solution 2

  ::1       sitename.local            # Local Site
  127.0.0.1 sitename.local            # Local Site
  ::1       www.sitename.local        # Local Site
  127.0.0.1 www.sitename.local        # Local Site

Just add above line to your hosts file and it will work, but do not forget to change ‘sitename’ to ‘yoursitename’.

Hope this helps others too.

1 Like

Thank you for sharing that @bhalashay!

I have tried all the solutons but still not fixed please help.

Can you share some more specifics?

OS - window 10
local version - 8.3.1
I have turned off my window defender and gave admin permission to HOST files.
local-log.zip (4.0 KB)

The errors in your logs still indicate some type of block or permissions issue is happening:

{"class":"Process","level":"warn","message":"nginx: [emerg] bind() to 0.0.0.0:80 failed (10013: An attempt was made to access a socket in a way forbidden by its access permissions)","process":"nginx","thread":"main","timestamp":"2024-03-14T18:00:08.171Z"}
{"class":"HostsFileService","error":{},"exitCode":{},"level":"error","message":"Could not update hosts.","stderr":{},"stdout":{},"thread":"main","timestamp":"2024-03-14T18:00:08.293Z"}
{"class":"Process","level":"warn","message":"nginx: [emerg] bind() to 0.0.0.0:80 failed (10013: An attempt was made to access a socket in a way forbidden by its access permissions)","process":"nginx","thread":"main","timestamp":"2024-03-14T18:00:10.158Z"}
{"class":"HostsFileService","error":{},"exitCode":{},"level":"error","message":"Could not update hosts.","stderr":{},"stdout":{},"thread":"main","timestamp":"2024-03-14T18:02:21.545Z"}

If you change your Router Mode to Localhost are you able to proceed? Preferences>Advanced>Router Mode>Localhost

Are you running other developer applications simultaneously? That could also cause similar issues. Apps like MAMP, XAMPP, or Docker for example.