How can I fix internet connection issues on wsl2

31,936

Solution 1

I was having the same issue. As the comment above suggested I disabled IPv6 option for both, my wireless adapter and WSL Ethernet adapter.

Follow the steps:

  1. Right click on your network icon, and click on Open Network and Internet settings image
  2. In the settings page look for Change adapter options under Advanced Network settings img
  3. On the next page you'll see a bunch of network adapters, for bluetooth, vpns, ethernet and for wifi.
  4. If you use wifi, then disable IPv6 for wifi and wsl adapters.
  5. Right click on the adapter and click Properties
  6. In the pop up look for a checkbox specifying IPv6 connection, uncheck it. img

I was trying to comment at first then couldn't (less reputations).

Solution 2

With my latest windows 10 ver 21H1 (OS Build 19043.1165) and the latest WSL2 Ubuntu-18.04. (On windows 11 Insider ver 21H2 (OS Build 22000.168) and fresh install of wsl2 ubuntu 18.04 it works well, the .wslconfig is correctly set with swapfile=0, it could be that when upgrading on the windows 10 from wsl1 to wsl2, since the .wslconfig was already there, that it was not freshly created correctly).

Thus, the simple procedure that works is to modify the c:\users%USERPROFILE%.wslconfig file to be:

[wsl2]    
memory=8GB    
**swapFile=0**    
swap=0

c:> wsl --shutdown c:> wsl

For some reason someone at microsoft changed the name of the swap config parameter. Stragely, when swapfile=0 is defined. wsl2's network works like a whistle.

Microsoft: Please decouple swalfile from network. And consider supporting both names for the swap.

Share:
31,936
bihire boris
Author by

bihire boris

I am a full stack developer. During my carrieer so far, I've developed software for mostly two platforms: mobile and web browsers. I can't live without Git. I like working on projects that make life easier.

Updated on September 18, 2022

Comments

  • bihire boris
    bihire boris over 1 year

    Just got on wsl2 and when I run sudo apt-get update I get the following error archive.ubuntu.com:80 (2001:503:83eb::30). - connect (101: Network is unreachable. What am I missing here?

    Note: I am on the official release to the public windows-10 updates 2004

    distro ubuntu 20.04 LTS

    According to old similar issues I should disable Avast, well in my case I don't have avast installed

    This is all the error

    bihire@DESKTOP-UJES0GS:~$ sudo apt-get update
    [sudo] password for bihire:
    Get:1 http://security.ubuntu.com/ubuntu focal-security InRelease [107 kB]
    Get:2 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages [101 kB]
    Get:3 http://security.ubuntu.com/ubuntu focal-security/main Translation-en [37.8 kB]
    Get:4 http://security.ubuntu.com/ubuntu focal-security/main amd64 c-n-f Metadata [2612 B]
    Get:5 http://security.ubuntu.com/ubuntu focal-security/restricted amd64 Packages [10.9 kB]
    Get:6 http://security.ubuntu.com/ubuntu focal-security/restricted Translation-en [2972 B]
    Get:7 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages [34.1 kB]
    Get:8 http://security.ubuntu.com/ubuntu focal-security/universe Translation-en [16.6 kB]
    Get:9 http://security.ubuntu.com/ubuntu focal-security/universe amd64 c-n-f Metadata [1428 B]
    Get:10 http://security.ubuntu.com/ubuntu focal-security/multiverse amd64 Packages [1172 B]
    Get:11 http://security.ubuntu.com/ubuntu focal-security/multiverse Translation-en [540 B]
    Get:12 http://security.ubuntu.com/ubuntu focal-security/multiverse amd64 c-n-f Metadata [116 B]
    Err:13 http://archive.ubuntu.com/ubuntu focal InRelease
      Cannot initiate the connection to archive.ubuntu.com:80 (2001:503:a83e::2:30). - connect (101: Network is unreachable)
    
    • Admin
      Admin almost 4 years
      WSL inherits the Windows network settings. Does your computer have IPv6 enabled on it for its network connections in the adapter settings?
    • Admin
      Admin almost 4 years
      do I need to enable more than this picture @ThomasWard
    • Admin
      Admin almost 4 years
      No, but I was asking because in Ubuntu if it sees an IPv6 connection available it will try and use the IPv6 connection (so therefore you may want to consider disabling IPv6 support in Windows on the interface unless you need it). Alternatively, try and force the use of IPv4 per this Unix and Linux post/answer within WSL.
    • Admin
      Admin almost 4 years
      disabled IPv6 still the same output this picture @ThomasWard
    • Admin
      Admin almost 4 years
      You may probably want to ask this in answers.microsoft.com/en-us or superuser.com
  • Edison Pebojot
    Edison Pebojot almost 3 years
    It doesn't work.
  • NotTheDr01ds
    NotTheDr01ds over 2 years
    Welcome to Ask Ubuntu. While this is useful information, you may want to phrase this as an alternative answer for readers for whom the other answers aren't working. Obviously, this is a new change as you mention, so it isn't the answer to the original question that was asked a year ago. So no, it isn't the "simple procedure that works" for everyone, obviously :) You should also point out which version of Windows this changed in, so that readers can check if that might be the problem. It wouldn't be useful for someone on an older release to try to update to the newer syntax.
  • Pranavan Maru
    Pranavan Maru about 2 years
    does not work!!