17

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?

René Link
  • 273
  • 1
  • 2
  • 6

1 Answers1

18

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*

But: Restarting Lxss* will terminate all your running WSL Instances.

bjoster
  • 4,423
  • 5
  • 22
  • 32