shayne / go-wsl2-host

Automatically update your Windows hosts file with the WSL2 VM IP address
1.65k stars 140 forks source link

Additional wsl2 aliases removed from hosts file after standby #18

Open tuhlmann opened 4 years ago

tuhlmann commented 4 years ago

This problem does not always occur. I think it does not occur if my laptop is on battery and goes to standby. It seems to regularly occur if its power connected and going to standby.

After wakeup I can't access my wsl aliases that I defined in .wsl2hosts anymore. Looking at the Windows hosts file they're gone and only the ubuntu.wsl address is included. Pinging this one from Windows seems to work.

I stopped the wslhost service and restarted it, but the hosts file didn't change. Then I closed wsl2 with wsl --shutdown and opened a new terminal to start it up again- this time Windows' hosts file contained all wsl aliases:

172.21.158.73 host.docker.internal    # alias: Ubuntu; managed by wsl2-host
172.21.158.73 wsl.local.com    # alias: Ubuntu; managed by wsl2-host
172.21.158.73 ubuntu.wsl    # managed by wsl2-host

Maybe you could advice a quicker workaround to properly refresh the hosts file, other than closing wsl2 or rebooting Windows?

Wsl2host has proven to be an invaluable tool working with wsl2- thank you so much!

robertoandrade commented 4 years ago

I'm noticing the same behavior and believe it's related to #9 and #19

robertoandrade commented 4 years ago

Tried reverting back to the 0.3.2 release, tried clearing the hosts file but still the same issue remains as described in the other issues.