How can I fix internet connection issues on wsl2

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.