No internet connection on WSL Ubuntu (Windows Subsystem for Linux) [closed]

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

To resolve this issue, follow the following steps.

  1. Locate the file by running the following command:

    sudo nano /etc/resolv.conf

You will see the following in the file:

# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/resolv.conf
# [network]
# generateResolvConf = false
nameserver xxx.xx.xx
  1. Change the nameserver value to 8.8.8.8 and save the file. You should now be able to connect to the internet.

Leave a Comment