WSL no internet connection

  1. DNS issues:

sudo rm /etc/resolv.conf
sudo bash -c 'echo "nameserver 8.8.8.8" > /etc/resolv.conf'
sudo bash -c 'echo "[network]" > /etc/wsl.conf'
sudo bash -c 'echo "generateResolvConf = false" >> /etc/wsl.conf'

The reason this error occurs is because Windows automatically generates resolv.conf file with wrong nameserver.

2. Open Command prompt as administrator

3. Use following commands:

netsh winsock reset 
netsh int ip reset all
netsh winhttp reset proxy
ipconfig /flushdns

4. Reboot machine

Last updated