Write to hosts file without password

This is a me problem but wondering if someone has advice i can pass along to my IT department…

What issue or error are you experiencing?

have a new company managed computer and my user is no longer an admin. Local is installed by user “root” in the “wheel” group but when creating or editing sites it requires the/an admin account password to update the host file.

we tired to update the sudoers file to allow running/opening Local.app as sudo without a password, but still prompts for admin account to edit file. can’t remember exact syntax but was something like::

local.user /usr/bin/open ALL=(ALL) NOPASSWRD: /usr/bin/open /Applications/Local.app

is there a way to allow the app access to edit the /etc/hosts file?


What steps can be taken to replicate the issue? Feel free to include screenshots, videos, etc


System Details

  • Local Version: Version 9.2.8+6882

  • Operating System (OS) and OS version: Mac OS 15.6.1 (24G90)


Local Logs

Attach your Local Logs here (Help Doc - Retrieving Local’s Log)


Security Reminder
Local does a pretty good job of scrubbing private info from the logs and the errors it produces, however there’s always the possibility that something private can come through. Because these are public forums, always review the screenshots you are sharing to make sure there isn’t private info like passwords being displayed.

Thanks for your question, @balbert.

Local doesn’t run sudo directly, so sudoers file entries won’t help. (Elevation needs to work via a GUI, so Local uses a library called @vscode/sudo-prompt that opens a GUI password dialog to ask for your permission, and that runs a temporary AppleScript applet to run the command with admin privileges once approved without calling sudo.)

Your best option if you can’t run as admin is to enable localhost router mode in Local’s advanced settings. When you do that, Local won’t prompt you for a password or try to write to /etc/hosts when you create a new site.

1 Like

Thanks @nickc .

That is interesting and didn’t know about that setting. Might give it a try to see how it works.

In the end, IT added a non-login “admin” account that allows me to elevate my privileges to write to /etc/hosts. Basically when prompted, I can use this account to do admin things.

1 Like

Thanks for the update, @balbert, I’m glad you were offered a workaround.

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