Uh-oh! Could not update hosts file

Local By flywheel can’t update my etc/ hosts file since last 3rd releases. I have to manually edit my host file to add or remove some domain name. I have a popup opening when i start a site which says “Uh-oh! Could not update hosts file”
“Local ran into a problem when trying to update the hosts file.” Please contact support if this persists". So here i am contacting you to solves this important problem :blush:

Note: I’ve already tried to give admin permission to the etc/hosts file and folder. But it didn’t change anything. I’m also using Mamp pro on my machine, Macbook MacOS Sierra 10.12.5

I think there is something to do with this file: update-hosts.js
This issue is related topic missing host entry but its not exactly the same problem i think
Here my latest localByFlywheel local logs file after updating to 2.0.6 and restart the software(see last part of logs) :

Jul 10, 2017, 10:27 AM GMT+2 - info: [main/index] Existing Pressmatic data does not exist.
Jul 10, 2017, 10:27 AM GMT+2 - info: [main/check-system] Check System: Docker Machine:  
{ stdout: 'Stopped\n', stderr: '' }
Jul 10, 2017, 10:27 AM GMT+2 - info: [renderer/CheckEnvPage] Check system promise response: [ undefined, 'machine-halted' ] machine-halted
Jul 10, 2017, 10:27 AM GMT+2 - info: [main/docker-machine] Checking Boot2Docker.iso hash
Jul 10, 2017, 10:27 AM GMT+2 - info: [main/docker-machine] Running  /Applications/Local by Flywheel.app/Contents/Resources/extraResources/virtual-machine/vendor/docker/osx/docker-machine start local-by-flywheel
Jul 10, 2017, 10:27 AM GMT+2 - info: [main/docker-machine] Starting "local-by-flywheel"...
Jul 10, 2017, 10:27 AM GMT+2 - info: [main/docker-machine] (local-by-flywheel) Check network to re-create if needed...
Jul 10, 2017, 10:27 AM GMT+2 - info: [main/docker-machine] (local-by-flywheel) Waiting for an IP...
Jul 10, 2017, 10:27 AM GMT+2 - info: [main/docker-machine] Machine "local-by-flywheel" was started.
Jul 10, 2017, 10:27 AM GMT+2 - info: [main/docker-machine] Waiting for SSH to be available...
Jul 10, 2017, 10:27 AM GMT+2 - info: [main/docker-machine] Detecting the provisioner...
Jul 10, 2017, 10:27 AM GMT+2 - info: [main/docker-machine] Started machines may have new IP addresses. You may need to re-run the `docker-machine env` command.
Jul 10, 2017, 10:27 AM GMT+2 - info: [main/set-docker-env] Getting Docker Machine env.
Jul 10, 2017, 10:27 AM GMT+2 - info: [main/set-docker-env] Received Docker Machine env.
Jul 10, 2017, 10:27 AM GMT+2 - info: [main/docker-machine] checking IP
Jul 10, 2017, 10:27 AM GMT+2 - info: [main/set-docker-env] Getting Docker Machine env.
Jul 10, 2017, 10:27 AM GMT+2 - info: [main/docker-machine] checked IP 192.168.75.100

Jul 10, 2017, 10:27 AM GMT+2 - info: [main/set-docker-env] Received Docker Machine env.
Jul 10, 2017, 10:28 AM GMT+2 - info: [main/index] All Local sites are stopped. Shutting down VM.
Jul 10, 2017, 10:29 AM GMT+2 - info: [main/index] Existing Pressmatic data does not exist.
Jul 10, 2017, 10:29 AM GMT+2 - info: [main/set-docker-env] Getting Docker Machine env.
Jul 10, 2017, 10:29 AM GMT+2 - info: [main/set-docker-env] Received Docker Machine env.
Jul 10, 2017, 10:29 AM GMT+2 - info: [renderer/CheckEnvPage] Check system promise response: [ undefined, true ] true
Jul 10, 2017, 10:29 AM GMT+2 - info: [main/startSite] Refreshing NFS mounts
Jul 10, 2017, 10:29 AM GMT+2 - info: [main/docker-router] getRouterContainers()
Jul 10, 2017, 10:29 AM GMT+2 - info: [main/docker-network-manager] maybeCreateNetwork
Jul 10, 2017, 10:29 AM GMT+2 - info: [main/hosts-helper] hostsHelper: Updating hosts with 192.168.75.100  ** mysql settings **   end ithemes security - ne pas modifier ou supprimer cette ligne  for bp multi network  ithemes security config details: 2  rename the wordpress wp-content directory  ssl aucoeurdulapin.dev define ( 'bp_root_blog', 2 ); define('bp_enable_multiblog', true); emeraude-emotions.dev inizi.dev mecanographik.socialwik.dev parthema-up.dev phoenix.dev pullrouge.dev socialwik.dev test.socialwik.dev test2local.dev testlocal.dev time2sail2.dev
Jul 10, 2017, 10:29 AM GMT+2 - info: [main/docker-router] reconnectNetwork()
Jul 10, 2017, 10:29 AM GMT+2 - info: [main/docker-network-manager] doesNetworkExist
Jul 10, 2017, 10:29 AM GMT+2 - info: [main/docker-network-manager] Network exists.
Jul 10, 2017, 10:29 AM GMT+2 - info: [main/docker-router] teardown()
Jul 10, 2017, 10:29 AM GMT+2 - info: [main/docker-router] Removing router container f647b6fde097a311d6031d6d8cc53765fcc90af6ecc3c5297968965ae478d02f
Jul 10, 2017, 10:29 AM GMT+2 - info: [main/docker-network-manager] Connected a570bb278e66e129e0fcb0fb0a4dcc31db7d9481bab5c2151264ea7d00658849.
Jul 10, 2017, 10:29 AM GMT+2 - info: [main/docker-network-manager] Connected fb54d89f30a5f619e68ea42e11cf5a6d568131de035a5a77b063ef05b3380b43.
Jul 10, 2017, 10:29 AM GMT+2 - info: [main/docker-network-manager] Connected d405249590c9d034c3568185ce3b9a6e8e159bc49140f71a3613ae60f44db517.
Jul 10, 2017, 10:29 AM GMT+2 - info: [main/docker-network-manager] Connected b2394694a433985e53d9c7fb839faa2241102c7349ec9417bc3972df92f6862b.
Jul 10, 2017, 10:29 AM GMT+2 - info: [main/docker-network-manager] Connected a90b0371fa1d8e149623cd62a10523573fb2ba81f7f97b02719fc77983d76e37.
Jul 10, 2017, 10:29 AM GMT+2 - info: [main/docker-network-manager] Connected da8ffadb3cac5c015050880bdc742377e34064f4884aa45e038e1b0bf21fbd75.
Jul 10, 2017, 10:29 AM GMT+2 - info: [main/docker-network-manager] Connected a6c907270c0dd14abcbbedb59d467a542fe7a9481eaeef2419f1558367814c0a.
Jul 10, 2017, 10:29 AM GMT+2 - info: [main/docker-network-manager] Connected 0ae6e6c456bcec23d8e270e02e98c335259dd8748b36d44c7860275585656e74.
Jul 10, 2017, 10:29 AM GMT+2 - info: [main/docker-network-manager] Connected 0117419ddbdcf3501df8f5e6ed94fa11d71b01a5905938638c37d2897ad9746f.
Jul 10, 2017, 10:29 AM GMT+2 - info: [main/docker-router] updateProxyManager()
Jul 10, 2017, 10:29 AM GMT+2 - info: [main/docker-router] runContainer()
Jul 10, 2017, 10:29 AM GMT+2 - info: [main/docker-network-manager] Connected 32314af4521abb17223b1aba0279d9687a623a641254241ccd15d218e6a4864e.
Jul 10, 2017, 10:29 AM GMT+2 - info: [main/waitForFile] Waiting for  /conf/php/7.0.3/etc/php-fpm.conf 32314af4521abb17223b1aba0279d9687a623a641254241ccd15d218e6a4864e
Jul 10, 2017, 10:29 AM GMT+2 - info: [main/waitForFile] /conf/php/7.0.3/etc/php-fpm.conf exists
Jul 10, 2017, 10:29 AM GMT+2 - info: [environment/custom]  Starting php-fpm  done
Jul 10, 2017, 10:29 AM GMT+2 - error: [main/hosts-helper] Could not update hosts. 
{ stdout: undefined,
  stderr: undefined,
  error: { code: 2 },
  exitCode: 2 }

Thanks for your help,
Regards

1 Like

Hi Pierre,

Sorry for the trouble!

Do you have any type of internet security or anti-virus installed? Some of them lock the /etc/hosts file.

Also, you may want to run First Aid on your macOS disk. See https://www.lifewire.com/repair-mac-drives-with-disk-utility-first-aid-4038562

Hi Clay,
Thanks for the link but i had already done that. I’ve tried to access to etc/host to with the mac terminal with sudo permission to make folder and files writable but it didn’t changed anything.
I have also stop my Little snitch network filter to give a try but its not the problem.

Do you have some command lines i can run from my terminal to give a new try on etc/hosts permissions ?

I have noticed something interesting, when i create a new host entry with Mamp pro (from the software interface) , Mamp Pro manage to edit etc/host file!

127.0.0.1 test.dev # MAMP PRO - Do NOT remove this entry!
::1 test.dev # MAMP PRO - Do NOT remove this entry!

i can see all my local flywheel host entries in the same host file by the way.

So, etc/hosts is writable for Mamp Pro but not for Local Flywheel :grimacing:

I also have change the chmod permission like this but it didn’t t change anything:
sudo chmod 664 /private/etc/hosts

i also open etc/hosts in finder and change permissions for the user’s ‘wheel’ to read and write but i have noticed that after restart local fly wheel, the user ‘wheel’ is back to ‘read only’ permission…

Local By FlyWheel still can’t modify the etc/hosts on my machine. Any idea where this bug come from in your app? Mamp pro don’t have such problem…

Pierre,

Can you please open Terminal, enter ls -la /etc/hosts and provide the output?

Any update on this? I’ve been having the same issue for the past few weeks (right after an update).

Cecil,

Are you on macOS or Windows? Also, can you please provide your local-by-flywheel.log?

Hi Clay,

I’m on Mac OS X 10.11.6 (15G1611)
Log file is attached.local-by-flywheel.log (6.4 KB)

Hi Cecil,

Do you have a multisite subdomain site in Local? If so, it looks like WP-CLI is outputting more than it should.

Specifically, I’m seeing this. It might be caused by a syntax error in your wp-config.php.

** mysql settings - you can get this info from your web host **   define( 'disallow_file_edit', true );  define('wp_post_revisions', false);  disable php error reporting which includes server file path  enable debug logging to the   enable wp_debug mode  force ssl

That’s right, there are a couple of sub-domain multisites.

Hi Clay,
I have opened my terminal and entered the command you have provided me and here is my output:

-rw-r--r--@ 1 root wheel 802 18 jul 23:00 /etc/hosts

What is the human traduction ? thanks

@mecanographik,

In Local 2.0.6 do you see an error when Local tries to update the hosts file?

Hi @clay in my local log file i have this

error: [main/hosts-helper] Could not update hosts. 
{ stdout: undefined,
  stderr: undefined,
  error: { code: 2 },
  exitCode: 2 }

and in my local by flywheel software, when i try to start a site, local ask me my macbook system password and than i have a popup saying

Uh-oh! could not update hosts file

did i mentioned that in the past i have tried to install trellis, but i have removed the folder from my computer

maybe there is a conflict somewhere with that?

sometimes, i have also this error when i try to launch local by flywheel :

info: [main/docker-machine-nfs] Enabling Docker Machine NFS
Aug 24, 2017, 4:11 PM GMT+2 - warn: [main/index] Unhandled Rejection at: Promise  Promise {
  <rejected> { error: 
   { Error: Command failed: sh "/Applications/Local by Flywheel.app/Contents/Resources/extraResources/shell-scripts/nfs-configure-mac.sh" "192.168.75.100" "501" "20"
   exports:2: path contains non-directory or non-existent components: /Users/Mecanographik/dev-sage/example.com/site
   exports:2: no usable directories in export entry
   exports:2: using fallback (marked offline): /
   exports:5: /Users conflicts with existing export /Users/Mecanographik/dev-sage/example.com/site
   
       at /Applications/Local by Flywheel.app/Contents/Resources/app.asar/node_modules/sudo-prompt/index.js:329:27
       at tryToString (fs.js:426:3)
       at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:413:12) code: 4 },
  stdout: undefined,
  stderr: undefined,
  exitCode: 4 } }  reason:  
{ error: { code: 4 },
  stdout: undefined,
  stderr: undefined,
  exitCode: 4 }

@ceciljchen @mecanographik

It looks like there might be syntax errors in one of your site’s wp-config.php files. It’s causing additional output in the WP-CLI command that fetches the subdomains for the multisite site.

I would make sure that the wp-config.php files for the multisites look correct.


@mecanographik

As far as the NFS issue goes, you can try opening /etc/exports with nano in Terminal (full command would be sudo nano /etc/exports).

You can remove every line in there and save it. Then, re-open Local.

1 Like

Thanks @clay the etc/exports command was useful to edit a vagrant old record i didn’t need anymore, than after i have fixed the NFC issues, Local By flywheel was starting nicely again. :grin:
Than i have also fixed my other big issues which was the unwritable hosts file. i have backed up and remove one of my local site, the one who was multi site mode, than the etc hosts file was writable again. Thanks so much Clay, you’re brillant! :star_struck:

Glad you got it working! :smiley: