microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
17.47k stars 822 forks source link

Updates don't work on WSL2 #5061

Closed Mystic8b closed 6 months ago

Mystic8b commented 4 years ago

Hi guys! After changing the version of WSL:

PS C:\WINDOWS\system32> wsl --set-version Ubuntu 2

Apt update doesn't work for me (and I waited for the execution of this command for about half an hour, why so long?...):

mystic@MYSTIC-OFFICEPC:/mnt/c/Users/Mystic$ sudo apt update
[sudo] password for mystic:
Hit:1 http://archive.ubuntu.com/ubuntu bionic InRelease
Err:2 http://security.ubuntu.com/ubuntu bionic-security InRelease
  Connection failed [IP: 91.189.88.142 80]
Err:3 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
  Connection failed [IP: 91.189.88.142 80]
Err:4 http://archive.ubuntu.com/ubuntu bionic-backports InRelease
  Connection failed [IP: 91.189.88.142 80]
Ign:5 http://archive.ubuntu.com/ubuntu bionic/universe amd64 Packages
Ign:6 http://archive.ubuntu.com/ubuntu bionic/universe Translation-en
Ign:7 http://archive.ubuntu.com/ubuntu bionic/multiverse amd64 Packages
Ign:8 http://archive.ubuntu.com/ubuntu bionic/multiverse Translation-en
Ign:5 http://archive.ubuntu.com/ubuntu bionic/universe amd64 Packages
Ign:6 http://archive.ubuntu.com/ubuntu bionic/universe Translation-en
Ign:7 http://archive.ubuntu.com/ubuntu bionic/multiverse amd64 Packages
Ign:8 http://archive.ubuntu.com/ubuntu bionic/multiverse Translation-en
Ign:5 http://archive.ubuntu.com/ubuntu bionic/universe amd64 Packages
Ign:6 http://archive.ubuntu.com/ubuntu bionic/universe Translation-en
Ign:7 http://archive.ubuntu.com/ubuntu bionic/multiverse amd64 Packages
Ign:8 http://archive.ubuntu.com/ubuntu bionic/multiverse Translation-en
Err:5 http://archive.ubuntu.com/ubuntu bionic/universe amd64 Packages
  Connection failed [IP: 91.189.88.142 80]
Ign:6 http://archive.ubuntu.com/ubuntu bionic/universe Translation-en
Ign:7 http://archive.ubuntu.com/ubuntu bionic/multiverse amd64 Packages
Ign:8 http://archive.ubuntu.com/ubuntu bionic/multiverse Translation-en
Reading package lists... Done
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-updates/InRelease  Connection failed [IP: 91.189.88.142
 80]
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-backports/InRelease  Connection failed [IP: 91.189.88.1
42 80]
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/bionic-security/InRelease  Connection failed [IP: 91.189.88.1
42 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic/universe/binary-amd64/Packages  Connection failed [IP:
91.189.88.142 80]
W: Some index files failed to download. They have been ignored, or old ones used instead.

And release upgrade too:

mystic@MYSTIC-OFFICEPC:/mnt/c/Users/Mystic$ sudo do-release-upgrade
[sudo] password for mystic:
Checking for a new Ubuntu release
Failed to connect to https://changelogs.ubuntu.com/meta-release-lts. Check your Internet connection or proxy settings
There is no development version of an LTS available.
To upgrade to the latest non-LTS develoment release
set Prompt=normal in /etc/update-manager/release-upgrades.

In this case, everything responds:

mystic@MYSTIC-OFFICEPC:/mnt/c/Users/Mystic$ ping security.ubuntu.com
PING security.ubuntu.com (91.189.88.142) 56(84) bytes of data.
64 bytes from aerodent.canonical.com (91.189.88.142): icmp_seq=1 ttl=56 time=54.2 ms
64 bytes from aerodent.canonical.com (91.189.88.142): icmp_seq=2 ttl=56 time=54.3 ms
64 bytes from aerodent.canonical.com (91.189.88.142): icmp_seq=3 ttl=56 time=54.2 ms
^C
--- security.ubuntu.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 54.289/54.329/54.399/0.049 ms
mystic@MYSTIC-OFFICEPC:/mnt/c/Users/Mystic$ ping archive.ubuntu.com
PING archive.ubuntu.com (91.189.88.142) 56(84) bytes of data.
64 bytes from aerodent.canonical.com (91.189.88.142): icmp_seq=1 ttl=56 time=54.2 ms
64 bytes from aerodent.canonical.com (91.189.88.142): icmp_seq=2 ttl=56 time=54.2 ms
64 bytes from aerodent.canonical.com (91.189.88.142): icmp_seq=3 ttl=56 time=54.3 ms
^C
--- archive.ubuntu.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 54.233/54.266/54.318/0.037 ms

After the rollback (wsl --set-version Ubuntu 1), there is no problem:

mystic@MYSTIC-OFFICEPC:/mnt/c/Users/Mystic$ sudo apt update
[sudo] password for mystic:
Get:1 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Hit:2 http://archive.ubuntu.com/ubuntu bionic InRelease
Get:3 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
Get:4 http://archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]
Get:5 http://archive.ubuntu.com/ubuntu bionic/universe amd64 Packages [8570 kB]
Get:6 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages [691 kB]
Get:7 http://security.ubuntu.com/ubuntu bionic-security/main Translation-en [221 kB]
Get:8 http://security.ubuntu.com/ubuntu bionic-security/restricted amd64 Packages [33.8 kB]
Get:9 http://security.ubuntu.com/ubuntu bionic-security/restricted Translation-en [8804 B]
Get:10 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 Packages [657 kB]
Get:11 http://security.ubuntu.com/ubuntu bionic-security/universe Translation-en [218 kB]
Get:12 http://security.ubuntu.com/ubuntu bionic-security/multiverse amd64 Packages [7176 B]
Get:13 http://security.ubuntu.com/ubuntu bionic-security/multiverse Translation-en [2764 B]
Get:14 http://archive.ubuntu.com/ubuntu bionic/universe Translation-en [4941 kB]
Get:15 http://archive.ubuntu.com/ubuntu bionic/multiverse amd64 Packages [151 kB]
Get:16 http://archive.ubuntu.com/ubuntu bionic/multiverse Translation-en [108 kB]
Get:17 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages [913 kB]
Get:18 http://archive.ubuntu.com/ubuntu bionic-updates/main Translation-en [314 kB]
Get:19 http://archive.ubuntu.com/ubuntu bionic-updates/restricted amd64 Packages [43.5 kB]
Get:20 http://archive.ubuntu.com/ubuntu bionic-updates/restricted Translation-en [10.9 kB]
Get:21 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages [1065 kB]
Get:22 http://archive.ubuntu.com/ubuntu bionic-updates/universe Translation-en [330 kB]
Get:23 http://archive.ubuntu.com/ubuntu bionic-updates/multiverse amd64 Packages [10.8 kB]
Get:24 http://archive.ubuntu.com/ubuntu bionic-updates/multiverse Translation-en [4728 B]
Get:25 http://archive.ubuntu.com/ubuntu bionic-backports/main amd64 Packages [2512 B]
Get:26 http://archive.ubuntu.com/ubuntu bionic-backports/main Translation-en [1644 B]
Get:27 http://archive.ubuntu.com/ubuntu bionic-backports/universe amd64 Packages [4020 B]
Get:28 http://archive.ubuntu.com/ubuntu bionic-backports/universe Translation-en [1900 B]
Fetched 18.6 MB in 15s (1255 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
28 packages can be upgraded. Run 'apt list --upgradable' to see them.

My system:

C:\Users\Mystic>ver
Microsoft Windows [Version 10.0.19041.172]

Internet connected via PPTP client. And as you can see, the internet works on PC and on WSL. But the updates for some reason do not work ... I freaked out and reinstalled WSL completely, but it gave me nothing.

dhikrahashim commented 4 years ago

Same issue for me also. Just installed ubuntu 18.04. not able to update

Mystic8b commented 4 years ago

The problem is resolved after reinstalling on ubuntu 20.04. Winver 19041.208

dhikrahashim commented 4 years ago

okay

rromanv commented 4 years ago

I have the same issue with Windows 19041.264

rromanv commented 4 years ago

If I revert back to WSL 1 everything works, just WSL 2 doesn't connect

Mystic8b commented 4 years ago

If I revert back to WSL 1 everything works, just WSL 2 doesn't connect

image Strange, everything works for me on the same build

rromanv commented 4 years ago

If I revert back to WSL 1 everything works, just WSL 2 doesn't connect

image Strange, everything works for me on the same build

wsl2 internet error

For me still, an issue, look at the powershell window, just error when I enabled wsl2

onomatopellan commented 4 years ago

@rromanv Try something like ping 216.58.192.164. Does it work?

rromanv commented 4 years ago

@rromanv Try something like ping 216.58.192.164. Does it work?

This works, that mean I have issues with DNS resolving?

rromanv commented 4 years ago

I followed up this, but instead of Google DNS I pointed to my company DNS (I need resolve of internal services/servers) https://github.com/microsoft/WSL/issues/4285#issuecomment-522201021

onomatopellan commented 4 years ago

Yes, that looks like DNS problem. You can see plenty of threads with similar issues but not an universal solution.

fle108 commented 4 years ago

i have the same issue when i'm connected over WiFi however i noticed that when i'm connected over ethernet it works well. i think issue is related to sharing network process between network cards over Hyper-v engine. WSL2 is not an emulation anymore but a specific hyper-v virtual machine that uses same network connexions that an hyper-v vm to connect (like virtual switch)...

markav2 commented 4 years ago

I turned off my VPN and I did not have an issue updating.

JayParikh20 commented 4 years ago

Tried everything, still can't get it to work. It works in WSL 1 but not 2.

whit-wu commented 4 years ago

Turning off my VPN fixed the issue for me as well.

luizwhite commented 4 years ago

Tried everything, still can't get it to work. It works in WSL 1 but not 2.

Same.. Also tried to update my network driver, and to reinstall WSL, but nothings changes:

Hit:1 http://archive.ubuntu.com/ubuntu focal InRelease
Err:2 http://security.ubuntu.com/ubuntu focal-security InRelease
  Connection failed [IP: 91.189.88.142 80]
Err:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease
  Connection failed [IP: 91.189.88.142 80]
Err:4 http://archive.ubuntu.com/ubuntu focal-backports InRelease
  Connection failed [IP: 91.189.88.142 80]
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal-updates/InRelease  Connection failed [IP: 91.189.88.142 80]
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal-backports/InRelease  Connection failed [IP: 91.189.88.142 80]
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/focal-security/InRelease  Connection failed [IP: 91.189.88.142 80]
W: Some index files failed to download. They have been ignored, or old ones used instead.

But, if i try to connect over Ethernet, or through my phone's wifi (routing), it works I'm not an advanced user, but I did everything right, it just dont work..

I guess these three are related

5867 #5831

luizwhite commented 4 years ago

It magically worked after this

mazharmahadik commented 4 years ago

I had Same problem with WSL2 , ubuntu distro. Basically you are not able to reach ubuntu servers on TCP connection. & that is why Ping & DNS resolution is working. Solution - Please check your Endpoint protection/Anti-virus agent/Windows Firewall. Try to disable them & then give a try. It worked for me. Later you can make permanent security exception for your wsl ubuntu. Now i am on wireless connection, my VPN connected, Security exception made on symantec protection, & still i can update all packages. HTH

P1100 commented 4 years ago

Turning off public network firewall solved it temporarily. Making the following firewall rule, in powershell, solved it completely:

New-NetFirewallRule -DisplayName "WSL" -Direction Inbound -InterfaceAlias "vEthernet (WSL)" -Action Allow

luizwhite commented 4 years ago

Turning off public network firewall solved it temporarily. Making the following firewall rule, in powershell, solved it completely:

New-NetFirewallRule -DisplayName "WSL" -Direction Inbound -InterfaceAlias "vEthernet (WSL)" -Action Allow

Not a PS expert here.. What exactly this code is doing?

P1100 commented 4 years ago

Turning off public network firewall solved it temporarily. Making the following firewall rule, in powershell, solved it completely: New-NetFirewallRule -DisplayName "WSL" -Direction Inbound -InterfaceAlias "vEthernet (WSL)" -Action Allow

Not a PS expert here.. What exactly this code is doing?

Makes a new windows firewall rule that allows the standard WSL interface to receive inbound packets (=> internet connection). Copy and paste it in the PowerShell admin console, after if you open Windows Firewall you will see the new created rule

luizwhite commented 4 years ago

@P1100 The rule didnt work for me.. Same issue.. Actually i have Bitdefender and I also tried to disable the firewall, but nothing changes..

The only thing that works until now is run sudo ifconfig eth0 mtu 1350 command everytime i start my WSL, and the internet magically start working:

terminal evidence ```zsh ❯ sudo apt update Hit:1 http://archive.ubuntu.com/ubuntu focal InRelease Hit:2 https://dl.yarnpkg.com/debian stable InRelease Err:3 http://security.ubuntu.com/ubuntu focal-security InRelease Connection failed [IP: 91.189.91.39 80] Err:4 http://archive.ubuntu.com/ubuntu focal-updates InRelease Connection failed [IP: 91.189.88.152 80] Err:5 http://archive.ubuntu.com/ubuntu focal-backports InRelease Connection failed [IP: 91.189.88.152 80] Reading package lists... Done Building dependency tree Reading state information... Done 61 packages can be upgraded. Run 'apt list --upgradable' to see them. W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal-updates/InRelease Connection failed [IP: 91.189.88.152 80] W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal-backports/InRelease Connection failed [IP: 91.189.88.152 80] W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/focal-security/InRelease Connection failed [IP: 91.189.91.39 80] W: Some index files failed to download. They have been ignored, or old ones used instead. ❯ sudo ifconfig eth0 mtu 1350 ❯ sudo apt update Hit:1 https://dl.yarnpkg.com/debian stable InRelease Get:2 http://security.ubuntu.com/ubuntu focal-security InRelease [107 kB] Hit:3 http://archive.ubuntu.com/ubuntu focal InRelease Get:4 http://archive.ubuntu.com/ubuntu focal-updates InRelease [111 kB] Get:5 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages [338 kB] Get:6 http://security.ubuntu.com/ubuntu focal-security/main amd64 c-n-f Metadata [4992 B] Get:7 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages [507 kB] Get:8 http://archive.ubuntu.com/ubuntu focal-backports InRelease [98.3 kB] Get:9 http://security.ubuntu.com/ubuntu focal-security/universe Translation-en [63.4 kB] Get:10 http://security.ubuntu.com/ubuntu focal-security/universe amd64 c-n-f Metadata [8500 B] Get:11 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [610 kB] Get:12 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 c-n-f Metadata [10.3 kB] Get:13 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [669 kB] Get:14 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 c-n-f Metadata [12.0 kB] Fetched 2540 kB in 2s (1144 kB/s) Reading package lists... Done Building dependency tree Reading state information... Done 63 packages can be upgraded. Run 'apt list --upgradable' to see them. ```
vineettalwar commented 4 years ago

https://github.com/microsoft/WSL/issues/5061#issuecomment-706714878 -> Solution is working for me. on windows defender Widnows 10 Pro 2004

rasert commented 4 years ago

I can't update too.

Nguimjeu commented 3 years ago

Nor the firewall solution or setting the mtu did work for me :-(

seibertr commented 3 years ago

Same issue with DNS resolving in WSL2 Debian fresh install. Editting /etc/resolv.conf and replacing bad line with "nameserver 8.8.8.8" solved the problem for me.

Nguimjeu commented 3 years ago

Same issue with DNS resolving in WSL2 Debian fresh install. Editting /etc/resolv.conf and replacing bad line with "nameserver 8.8.8.8" solved the problem for me.

Well I did add the entrry nameserver 8.8.8.8, but beind coorporate VPN apt-get update does not work. Adding the DNS of from the VPN allows to access coorporate network but then that's it. Digging...

eldano1995 commented 3 years ago

New-NetFirewallRule -DisplayName "WSL" -Direction Inbound -InterfaceAlias "vEthernet (WSL)" -Action Allow

Your rule did worked for me: New-NetFirewallRule -DisplayName "WSL" -Direction Inbound -InterfaceAlias "vEthernet (WSL)" -Action Allow

I'll give a little more details about my situation, because it might not applied to everyone:

I was using the internet connection of my company, which uses it's own proxy company.proxy.com:port (I use proxifier to control which apps should have Internet access using that proxy).

Also, because of the country I lived in, I don't have access to some websites, so I need to use a VPN (I use profixier to control which apps must should make the request via VPN and what should not).

Funny enough, it seems that http://archive.ubuntu.com/ubuntu belongs to one of those websites I don't have access to, so the requests that my WSL make should go through the VPN (which is hard to do because proxifier does not detect any network traffic from wsl.exe, the same as when it doesn't detect network traffic from cmd.exe when we do ping google.com)

So, that's more or less my situation. This is what I did: 1 - I disabled the IPv6 element from Ethernet Network and allowed "Used share network" (but I don't think this had anything to do on solving the issue, so you might try skipping this step) image

2 - Installed CCProxy, and mounted a proxy server on my machine

3 - Created a rule on proxifier so that the connection of the VPN app goes through the company proxy

4 - Created another rule on proxifier so that everything that goes through CCProxy goes by the VPN app

5 - I run on wsl: sudo nano /etc/apt/apt.con

6 - Added this line to apt.con: Acquire::http::Proxy "http://`**CCProxy_configured_IP**:**CCProxy_configured_HTTPS_port**";

7- Added rule using Powershell as admin: New-NetFirewallRule -DisplayName "WSL" -Direction Inbound -InterfaceAlias "vEthernet (WSL)" -Action Allow

And I think that was it: Now, every wsl conecction (at least when I do apt-get update) is allowed (by rule in step 7), then it makes the request to CCProxy (steps 6 )), and then CCProxy forwards the request to the VPN (step 4, 3)

EngineerFaunce commented 3 years ago

Adding this firewall rule did not work for me.

Running Windows 10 Pro 2004 with Ubuntu 20.04 on WSL2

Downgrading to WSL1 "fixes" the issue.

EDIT: After some more google searching I stumbled upon this comment from #5336 which fixed my issue.

I believe there was some trouble going on with the Hyper-V network adapter for WSL, but this is only my uneducated guess.

Nguimjeu commented 3 years ago

Small addition for my specific case: I had to configure the proxy settings for APT in order to be able to successfully run update and upgrade commands. If that's the case for you guys. try this:

  1. Create a new configuration file named proxy.conf proxy.conf

    > sudo touch /etc/apt/apt.conf.d/proxy.conf
  2. Open the proxy.conf file in a text editor.

    > sudoedit /etc/apt/apt.conf.d/proxy.conf
  3. Add the following lines to set your corporate HTTP(S) proxy.

    Acquire {
        HTTP::proxy "http://corporate.proxy.address.com:port";
        HTTPS::proxy "http://corporate.proxy.address.com:port";
    }
  4. Save your changes and exit the text editor.

You should be able to run apt command next time.

brianwyka commented 3 years ago

Thanks @Nguimjeu, appreciate you sharing this. Worked for me on WSL2 Ubuntu 20.04

Windows 10 1909 Build 18363.1316

Corporate VPN (AnyConnect VPN Client)

Corporate Proxy

Francis-Tao-jinjin commented 3 years ago

It is fucking amazing to see this bug has not been solved for years, I was planning to use windows for development, and I found that even gcc could not be installed in wsl due to this bug. What the hell Microsoft is doing?

waseidel commented 3 years ago

Small addition for my specific case: I had to configure the proxy settings for APT in order to be able to successfully run update and upgrade commands. If that's the case for you guys. try this:

  1. Create a new configuration file named proxy.conf proxy.conf
    > sudo touch /etc/apt/apt.conf.d/proxy.conf
  2. Open the proxy.conf file in a text editor.
    > sudoedit /etc/apt/apt.conf.d/proxy.conf
  3. Add the following lines to set your corporate HTTP(S) proxy.
    Acquire {
        HTTP::proxy "http://corporate.proxy.address.com:port";
        HTTPS::proxy "http://corporate.proxy.address.com:port";
    }
  4. Save your changes and exit the text editor.

You should be able to run apt command next time.

I use this and the seventh step of this https://github.com/microsoft/WSL/issues/5061#issuecomment-756457106 and works, all was because i'm behind a proxy and I have to tell linux my credentials to access

axd465 commented 3 years ago

Had the same issue on OS Build 19042.906. For me the issue came from my anti-virus software. Imagine the issue could also come from VPN level network traffic restrictions. General solution might be to turn off anti-virus/VPN, do sudo apt-get update, and turn anti-virus/VPN back on. This clearly may not be the best idea for those with more credible security threats, but could be an acceptable risk for more general users. For my specific anti-virus, Symantec, I went to Change Settings, Configure Settings for the Network and Host Exploit Mitigation, and under the Firewall tab changed the Unmatched IP Traffic Settings from Allow only application traffic to Allow IP traffic. There may be similar settings in other anti-virus software that could cause similar issues. If this solution fails, there may be other network level restrictions causing issues, so that might be the best place to start. Hope this helps others out with the same issue.

parthokr commented 3 years ago

This is very annoying and still, this bug has not been solved.

kbillore commented 3 years ago

Check what antivirus you are using. I was having McAfee and endpoint security enabled. If disconnect End Point security firewall connectivity will work straightaway (no reboot required).

https://kc.mcafee.com/corporate/index?page=content&id=KB91411

gokulmkrish commented 3 years ago

Small addition for my specific case: I had to configure the proxy settings for APT in order to be able to successfully run update and upgrade commands. If that's the case for you guys. try this:

  1. Create a new configuration file named proxy.conf proxy.conf
    > sudo touch /etc/apt/apt.conf.d/proxy.conf
  2. Open the proxy.conf file in a text editor.
    > sudoedit /etc/apt/apt.conf.d/proxy.conf
  3. Add the following lines to set your corporate HTTP(S) proxy.
    Acquire {
        HTTP::proxy "http://corporate.proxy.address.com:port";
        HTTPS::proxy "http://corporate.proxy.address.com:port";
    }
  4. Save your changes and exit the text editor.

You should be able to run apt command next time.

After this exact steps i just entered "sudo apt update". got an bunch of errors. then, i commented the proxy file contents. then I executed the same command "sudo apt update". It works fine. ' FYI: I didn't connected through the VPN

anthonyzhub commented 3 years ago

Updating Windows worked for me. Make sure to check "optional updates" as well.

Mythologyli commented 3 years ago

@P1100 The rule didnt work for me.. Same issue.. Actually i have Bitdefender and I also tried to disable the firewall, but nothing changes..

The only thing that works until now is run sudo ifconfig eth0 mtu 1350 command everytime i start my WSL, and the internet magically start working:

terminal evidence

Thanks a lot. That works. I'm using L2TP to access the Internet, and I think this error only happens when I using it. Maybe big MTU can't work in L2TP.

akatebi commented 3 years ago

In the Ubuntu shell do this:

sudo hwclock --hctosys

It worked for me.

hungran commented 3 years ago

I used WSL1 then upgraded to WSL2 from last 2020 after that faced this issue till now, I gave up and swap to use Macbook 🍎 🤪 🤪 Today when I'm trying to update Windows 11 then I found the solution, just disabled my Antivirus Software Symantec Endpoint Protection Microsoft Windows [Version 10.0.19043.1083] WSL2 Ubuntu 18.04 SEP ver: image

Thanks God, It worked finally but such WSL2 👎, change the solution for network pleaseeeee!!!!!!!!!!!

noeklk commented 3 years ago

Same issue with DNS resolving in WSL2 Debian fresh install. Editting /etc/resolv.conf and replacing bad line with "nameserver 8.8.8.8" solved the problem for me.

Well I did add the entrry nameserver 8.8.8.8, but beind coorporate VPN apt-get update does not work. Adding the DNS of from the VPN allows to access coorporate network but then that's it. Digging...

Do ipconfig /all, get the DNS servers, for example to me it was : 172.x.x.x and 172.x.x.x Edit your /etc/resolv.conf, if with only "nameserver 8.8.8.8" doesn't work, add the 2 dns servers as follow

nameserver 172.x.x.x
nameserver 172.x.x.x
Tenoke commented 3 years ago

I'm still having this issue on a fresh install today with everything updated. Adding 8.8.8.8 instead of the default nameserver helped but I also did near everything in those threads.

parthokr commented 3 years ago

Finally ditched wsl2.

Adriano-Santtos commented 3 years ago

I was having this same problem. My antivirus is Avast, I just disabled it for a few minutes and the command worked.

chintanp commented 3 years ago

@Adriano-Santtos I had the same problem and disabling Avast helped. But does not seem like a solution. Please update if and when you resolve this. My OS build info:

Edition Windows 10 Home
Version 20H2
Installed on    ‎8/‎18/‎2021
OS build    19042.1202
Experience  Windows Feature Experience Pack 120.2212.3530.0
chintanp commented 3 years ago

On further Googling, I found this solution and it seems to work: https://github.com/MicrosoftDocs/WSL/issues/481

MaxiPalle commented 3 years ago

Check what antivirus you are using. I was having McAfee and endpoint security enabled. If disconnect End Point security firewall connectivity will work straightaway (no reboot required).

https://kc.mcafee.com/corporate/index?page=content&id=KB91411

McAffee product was in our case the problem. Thanks @kbillore for pointing us into this direction!

kbillore commented 3 years ago

Check what antivirus you are using. I was having McAfee and endpoint security enabled. If disconnect End Point security firewall connectivity will work straightaway (no reboot required). https://kc.mcafee.com/corporate/index?page=content&id=KB91411

McAffee product was in our case the problem. Thanks @kbillore for pointing us into this direction!

I think we can close this open thread now.

Tenoke commented 3 years ago

Check what antivirus you are using. I was having McAfee and endpoint security enabled. If disconnect End Point security firewall connectivity will work straightaway (no reboot required). https://kc.mcafee.com/corporate/index?page=content&id=KB91411

McAffee product was in our case the problem. Thanks @kbillore for pointing us into this direction!

I think we can close this open thread now.

But the issue still hasn't been fixed. I still need to have 8.8.8.8 in /etc/resolv.conf which isn't ideal. This wasn't an issue in wsl1.