12

When I start the first WSL terminal (ubuntu 20.04 bash in my case), WSL generates the /etc/hosts file based on the host file of my windows system %WINDIR%\System32\drivers\etc\hosts.

If I now change the %WINDIR%\System32\drivers\etc\hosts, e.g. add some entries, the /etc/hosts in my WSL is not updated. Even if I close all WSL terminals and open a new one. Only reboot of my windows system helps.

Is there a way I can manually trigger the update of the /etc/hosts so that I do not have to reboot?

15

As long as this

[network]
generateHosts = true
generateResolvConf = true

is in your /etc/wsl.conf a restart of the LxssManager* services should do the trick.

Restart-Service LxssManager*
2
  • 3
    It works. I just had to execute Restart-Service LxssManager* in a power shell that was started with admin rights.
    – René Link
    Nov 17 '20 at 17:55
  • 1
    It also worked for my although I don't have those entries in wsl.conf May 25 at 12:56

Not the answer you're looking for? Browse other questions tagged or ask your own question.