Windows10 WSL2 Ubuntu / Debian # no network
Solution 1:
The generated file /etc/resolv.conf is:
nameserver 172.24.0.1
..had to change it to
nameserver 8.8.8.8
which resolves the problem
Solution 2:
Original Answer:
In my case I was using a VPN in Windows, when disconnecting from the VPN the problem was resolved.
Edit:
However, this is becoming a wider issue, it's happened again to me and I've solved it by removing Hyper-V Virtual Switch Extension Adapter.
The two solutions most widely used at the moment for this issue are:
1 Prevent /etc/resolfv.conf to become "corrupted"
- Create a file:
/etc/wsl.conf
. - Put the following lines in the file
[network]
generateResolvConf = false
- In a
cmd
window, runwsl --shutdown
- Restart WSL2
- Create a file:
/etc/resolv.conf
. If it exists, replace existing one with this new file. - Put the following lines in the file
nameserver 8.8.8.8
- Repeat step 3 and 4. You will see
git
working fine now.
Credits to NonStatic who shared it on github
2 Remove corrupted Network Interface Drivers (could be permanent)
-
First go to device manager
-
Show hidden devices
-
Delete all Hyper-V Virtual Switch Extension Adapter
Credits to Jaysonsantos who shared it on GitHub