Hi, quick tip. I encountered this behavior where WSL was very slow on pings, file edits, and other interactions. The problem is that the /etc/hosts file has an automatically added entry for the local machine but in the wrong format.
Take my wrong host file as an example:
# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateHosts = false
127.0.0.1 localhost
127.0.1.1 Home-Z97. Home-Z97
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
My machine is called Home-Z97, the entry "Home-Z97. Home-Z97" is wrong. You need to change it to: "Home-Z97"
Here is the correct full file:
# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateHosts = false
127.0.0.1 localhost
127.0.1.1 Home-Z97
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
Save this and edit the file /etc/wsl.conf. Add the generatedHosts = false flag
[network]
enerateHosts = false
Restart WSL with the command in PowerShell: wsl --shutdown
This is a bizarre problem, and I came up with the solution by accident.
This solves the problem on two different machines. I hope that helps! ๐
ย