Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WSL2 HTTPS Connections Timeout #6416

Open
edarioq opened this issue Jan 10, 2021 · 38 comments
Open

WSL2 HTTPS Connections Timeout #6416

edarioq opened this issue Jan 10, 2021 · 38 comments
Labels

Comments

@edarioq
Copy link

edarioq commented Jan 10, 2021

Environment

Microsoft Windows [Version 10.0.19042.685]
Release: 20.04
WSL2
Linux version 4.19.128-microsoft-standard (oe-user@oe-host) (gcc version 8.2.0 (GCC)) #1 SMP Tue Jun 23 12:58:10 UTC 2020

Steps to reproduce

For example, trying to install NVM fails with a timeout error.

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash

After further debugging I found that the script just tries to clone the repo using https. I then tried to clone any repo via https and it fails with a timeout error, SSH works perfectly fine.

WSL logs:
https://gist.github.com/edarioq/0198119f6c461b4025a3344a354b8d20

Expected behavior

https connections should work and git clone should work without any timeouts.

Actual behavior

fatal: unable to access 'https://github.com/nvm-sh/nvm.git/': Operation timed out after 300038 milliseconds with 0 out of 0 bytes received

Things I've tried:

  • Changing MTU
  • Reinstalling (brand new Windows and Ubuntu install)
  • Disabling IPv6
  • Updating Git
  • Updating network drivers
@edarioq
Copy link
Author

edarioq commented Jan 15, 2021

Awesome support from the Microsoft team, guess it's back to good old Mac OS for my development needs.

@OneBlue
Copy link
Collaborator

OneBlue commented Jan 29, 2021

Thanks for reporting the issue @edarioq .

Can you please follow these instructions and share the script output, and both wsl.etl and packets.etl ?

@FremyCompany
Copy link

Hi @OneBlue,

I'm a former Microsoft employee. I filed feedback about what might be a similar issue here: https://aka.ms/AAaztwh (and I included networking diagnostics).

Let me know if you need any help looking at this, I am willing to run further diagnosis if needed, as this is a blocking issue for me at the moment.

While my computer is in the hung network state, it is probably spamming the network one way or another, because my mom can't watch the television until I unplug the network cable and replug it.

@FremyCompany
Copy link

In case anyone wonders what to do in this situation, my solution for now has been to install Telerik Fiddler on the Windows side, and setup my Linux machine to use it as a proxy. Because of that trick, all traffic to the web is routed through Windows instead of Linux, and that has prevented the network connection from hanging so far.

Additional instructions
  1. Install Telerik Fiddler
  2. Configure Fiddler to enable proxying VMs
    2.1. Enable external connections to the proxy
    2.2. Enable interception of HTTPS traffic
    2.3. Enable response streaming (New Fiddler version: click on the first button of the toolbar (called "Stream responses" on hover))
  3. Export Fiddler's certificate to your desktop, then install that certificate as root on Linux
sudo mkdir /usr/share/ca-certificates/extra
sudo cp /mnt/c/Users/franc/Desktop/FiddlerRootCertificate.crt /usr/share/ca-certificates/extra
sudo dpkg-reconfigure ca-certificates
  1. Enable connections to go through your firewall
In the Windows firewall, add an inbound rule to enable port 8866
  1. Find your IP address
grep -m 1 nameserver /etc/resolv.conf | awk '{print $2}'
  1. Enable the proxy temporarily for the system:
export http_proxy=172.25.112.1:8866
export https_proxy=172.25.112.1:8866
  1. Enable the proxy for apt-get
sudo nano /etc/apt/apt.conf
Acquire::http::Proxy "http://172.25.112.1:8866";
Acquire::https::Proxy "http://172.25.112.1:8866";
  1. Enable the proxy for pip
mkdir /home/fremy/.config/pip/
vi /home/fremy/.config/pip/pip.conf
[global]
trusted-host = pypi.python.org
               pypi.org
               files.pythonhosted.org

@ppejovic
Copy link

ppejovic commented Feb 10, 2021

I've been experiencing something potentially similar for the past 2-3 weeks (I can't see the Feedback Hub submission @FremyCompany) . Larger downloads with curl will slowly degrade in download speed until the speed reaches zero, then curl just hangs without the download ever completing. It's possible this is affecting all downloads, it's just that the behaviour is easily observable with 30+ MB downloads. This has completely blocked me from using WSL, however @FremyCompany's fiddler proxy workaround has actually made it useable.

However, in my case I don't believe this is WSL specific as I've observed the same behaviour in an Ubuntu Hyper-V VM. Since WSL2 uses Hyper-V and generates a dedicated WSL Hyper-V switch I can only assume it is something in the Hyper-V virtual network stack.

Here are a couple of downloads that typically stall:

curl -L https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip -o /dev/null
curl -L https://github.com/backstage/backstage/archive/master.zip -o /dev/null

I have tried multiple things to address this (recreating the virtual switch, disabling AV), however I have experienced this on multiple machines including a freshly re-imaged Windows 10 20H2. I'm in a corporate environment so the desktops get installed with an array of bloatware but at this point the only culprit is a Jan 2021 Windows Patch that mentions security updates to "Windows Virtualization": https://support.microsoft.com/en-us/topic/january-12-2021-kb4598242-os-builds-19041-746-and-19042-746-ab18a1a1-d572-598f-4d86-7137aad34056

@dlakatos847
Copy link

dlakatos847 commented Apr 29, 2021

I think the issue is more generic than some HTTPS URLs. I suspect it's a Hyper-V related TCP NAT problem. ICMP echo requests are transmitted and responded and UDP-based DNS queries can succeed also. No TCP connection can be established though (eg. with nc). I'm on Windows 10 x64 Pro 20H2 19042.928, WSL2 running OpenSuSE Tumbleweed.

@dlakatos847
Copy link

Windows update resolved my TCP NAT problem. I'm on Windows 10 x64 Pro 20H2 19042.964 now.

@FremyCompany
Copy link

I think this issue can be closed indeed. There was a networking driver update and that fixed this issue for me as well, quite a while ago in fact.

@ecalcutin
Copy link

Might it be related to #7254 ?

@rstone
Copy link

rstone commented Oct 12, 2021

Was related to an open VPN connection for me. Once that was closed no more timeouts.

@bhargavmodak
Copy link

bhargavmodak commented Feb 9, 2022

Well I am getting the same issue; about an year later than the Original Post.
I'm on Microsoft Windows 11 Pro | Version 10.0.22000.493, and I run into the same issue on WSL2.

I think this issue can be closed indeed. There was a networking driver update and that fixed this issue for me as well, quite a while ago in fact.

An automatic one by Windows update, or a manual one?

Update :

I went to the actual Github repository and there they had this option :
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash

It seemed to work, and $ command -v nvm returns nvm after a restart of the terminal.
I do not know if this is the right way to do this, however.

@kmshort
Copy link

kmshort commented Apr 5, 2022

I'm having this exact same problem now. Fresh Windows 11 Enterprise update, running WSL2/g. wget downloads sometimes time out, sometimes they works In other software, R, the same thing happens when grabbing packages from online repositories. It's a big problem.

@bhargavmodak
Copy link

Update :

I went to the actual Github repository and there they had this option :
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash

It seemed to work, and $ command -v nvm returns nvm after a restart of the terminal.
I do not know if this is the right way to do this, however.

It is not. Any future installations of node suffer timeouts. It was strange to have my git on WSL and Node on Windows, so I had to reinstall git for windows. While WSL is good for simulating other features in Linux, not having nvm and Node.js really restricts any development environment.

@brunoAltinet
Copy link

If someone stumbles here, i couldnt get brew package to install, so fiddling with MTU seems to fix it (althought i did try a couple of things).
#4698 (comment)
Note that on my side mtu 1350 vEthernet (WSL)

@znmeb
Copy link

znmeb commented Apr 23, 2022

I've got this now, I'm not sure when it started; I've only been doing WSL-intensive networking for a week or so. System specs:

Edition	Windows 11 Pro
Version	21H2
Installed on	‎2022-‎01-‎15
OS build	22000.613
Experience	Windows Feature Experience Pack 1000.22000.613.0

This is WSL preview - the one that supports GUI applications. I haven't tried dropping back to the default version. Here's the diagnostic run (network.log is the logfile of the network.bat run).

diagnostics.zip

@plabon-asad
Copy link

WSL2-network-connection-timeout

I am getting this timeout issue.
Any solution guys?

@CoryKniefel
Copy link

If anyone end up here, make sure you try updating your kernel (powershell as admin): wsl --update.

@znmeb
Copy link

znmeb commented Sep 29, 2022

If anyone end up here, make sure you try updating your kernel (powershell as admin): wsl --update.

  1. Doesn't that happen automatically if you select "update all Microsoft products" in your update settings?
  2. Is this bug still open? It's been a while since I did any intensive downloading in WSL.

@CoryKniefel
Copy link

If anyone end up here, make sure you try updating your kernel (powershell as admin): wsl --update.

  1. Doesn't that happen automatically if you select "update all Microsoft products" in your update settings?
  2. Is this bug still open? It's been a while since I did any intensive downloading in WSL.

Not sure how all that works. But wsl --status told me I had auto updates off, and that there was an update available. I've already ran all of the windows updates manually, and had the exact problem described by original post.

@lemonsaurus
Copy link

If anyone end up here, make sure you try updating your kernel (powershell as admin): wsl --update.

I was having this problem on a fresh install of Windows 11, with a fresh Ubuntu 22.04 distro, with all windows updates installed. wsl --update solved the problem for me. Thanks @CoryKniefel!

@toadharvard
Copy link

toadharvard commented Oct 24, 2022

Same problem. wsl --update can't solve problem because The most recent version of Windows Subsystem for Linux is already installed.

root@laptop:~# curl -vfsSL https://apt.releases.hashicorp.com/gpg
*   Trying 65.9.44.100:443...
* Connected to apt.releases.hashicorp.com (65.9.44.100) port 443 (#0)
* ALPN: offers h2
* ALPN: offers http/1.1
*  CAfile: /etc/ssl/certs/ca-certificates.crt
*  CApath: /etc/ssl/certs
* TLSv1.0 (OUT), TLS header, Certificate Status (22):
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS header, Certificate Status (22):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS header, Finished (20):
* TLSv1.2 (IN), TLS header, Supplemental data (23):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.2 (IN), TLS header, Supplemental data (23):
* SSL connection timeout
* Closing connection 0
curl: (28) SSL connection timeout

Any suggestions?

@ralphv
Copy link

ralphv commented Oct 28, 2022

Same issue, clean fresh machine, Windows 11...
In my case when I do npm install, I get a lot of timeouts and blocking...

@JoshTheDeveloperr
Copy link

JoshTheDeveloperr commented Oct 30, 2022

I'm not sure why but this Stack Overflow answer fixed the problem for me. https://stackoverflow.com/a/70782306

For some reason the name resolution for https://registry.npmjs.org isn't resolving or is just extremely slow when using the stock resolv.conf configuration.

@znmeb
Copy link

znmeb commented Oct 30, 2022

I'm not sure why but this Stack Overflow answer fixed the problem for me. https://stackoverflow.com/a/70782306

For some reason the name resolution for https://registry.npmjs.org isn't resolving or is just extremely slow when using the stock resolv.conf configuration.

Interesting ... why should changing the DNS server fix this? Is there something wrong with the automatically generated DNS server that WSL wrote into the file?

@RingoDev
Copy link

RingoDev commented Oct 30, 2022

Also experiencing a similar problem:

  • pnpm installs show many ERR_SOCKET_TIMEOUT and unusually long install times.

EDIT: setting nameserver to 8.8.8.8 in resolv.conf resolved the issue temporarily

@znmeb
Copy link

znmeb commented Oct 30, 2022

Also experiencing a similar problem:

* pnpm installs show many `ERR_SOCKET_TIMEOUT` and unusually long install times.

EDIT: setting nameserver to 8.8.8.8 in resolv.conf resolved the issue temporarily

I still don't get why hard-coding the nameserver to Google's DNS is faster than using the internal nameserver that Windows / WSL provide. Where is the extra time going in the software as shipped? Should Microsoft change something?

@Tabares
Copy link

Tabares commented Nov 15, 2022

Please try the following in your WSL

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'
sudo chattr +i /etc/resolv.conf

I can install with curl.

@Larenatos
Copy link

Larenatos commented Dec 3, 2022

Please try the following in your WSL

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'
sudo chattr +i /etc/resolv.conf

I can install with curl.

Using Google's DNS didn't resolve the issue for me. Still timing out despite working on windows.

➜  ~ curl -v https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh
*   Trying 185.199.108.133:443...
* TCP_NODELAY set
* Connected to raw.githubusercontent.com (185.199.108.133) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: /etc/ssl/certs
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* Operation timed out after 300164 milliseconds with 0 out of 0 bytes received
* Closing connection 0
curl: (28) Operation timed out after 300164 milliseconds with 0 out of 0 bytes received

@Driftminder
Copy link

Hello,

I've got the same trouble and try all this solution:

Current : Windows 10 22H2 19045.2251

  • Update Kernel : 5.10.102.1-microsoft-standard-WSL2
  • Update Windows to 22H2 latest possible
  • Uninstall WSL / HyperV / VM Windows plateform
  • Try Debian insteed of Ubuntu in WSL

Everything doesn't work, at least i've found a solution for me, change the MTU of the eth0 in WSL to 1350, after this my apt update / upgrade / install work properly.

This is command to use

sudo ip link set dev eth0 mtu 1350

@cgagnonqc
Copy link

I have the same issue and tried all proposed solutions above. None worked. I also tried solutions there , none worked.

I end up trying removing Docker desktop for Windows and only installing it like a native Linux.
I also activated systemd support.
https://nickjanetakis.com/blog/install-docker-in-wsl-2-without-docker-desktop

I works well and didn't get any troubles.

@lxe
Copy link

lxe commented Apr 16, 2023

I'm running into https timeouts on WSL with windows 11. Just checking in.

@gyohza
Copy link

gyohza commented Sep 22, 2023

I was having the same problem, but only after upgrading WSL to WSL2.

I tried changing SSH keys, switching to HTTPS, deleting the repo and failing to clone back again, blaming my VPN, punching my screen... the error wouldn't budge.

Then I just used powershell to downgrade it back:

wsl --set-version Ubuntu-20.04 1

And then everything started working again 🤡

@portwatcher
Copy link

sudo hwclock -s
syncing system time with windows works for me

@nicejin74
Copy link

Checking Docker desktop on

@DominikM
Copy link

Want to chime in here to add my own experience with this issue. All https requests would fail by timing out, and every fix listed here didn't help. It clearly wasn't a DNS issue because urls could be correctly resolved to IP addresses. Ultimately it turned out that that the Hyper-V firewall was blocking WSL in a way that caused it to fail. Running these commands in powershell fixed my issue:

Set-NetFirewallHyperVVMSetting -Name '{40E0AC32-46A5-438A-A0B2-2B479E8F2E90}' -DefaultInboundAction Allow
Set-NetFirewallHyperVVMSetting -Name '{40E0AC32-46A5-438A-A0B2-2B479E8F2E90}' -AllowHostPolicyMerge False

The first command modifies the firewall to allow all inbound connections by default. This should probably be a bit more precise to avoid unwanted traffic, but as a first pass it worked. The second command is necessary to prevent the host firewall policy from overriding the locally set values. After this, everything worked as expected.

@fooyun
Copy link

fooyun commented Feb 7, 2024

same problem, and still have no idea

@CaoKha
Copy link

CaoKha commented Feb 12, 2024

installing with curl, with ethernet connection, first try failed but second try after Ctrl+C worked, still have no idea....

@jess-disguise
Copy link

I started getting many different but related errors where I previously had no issues. Setup is WSL2 using Ubuntu 22.04 + Windows 11, building Docker images that contain RUN composer install --ignore-platform-reqs --optimize-autoloader :

  • A connection timeout was encountered. If you intend to run Composer without connecting to the internet, run the command again prefixed with COMPOSER_DISABLE_NETWORK=1 to make Composer run in offline mode.
  • Resolving timed out after 10000 milliseconds
  • SSL Connection timed out
  • etc...

Setting RUN COMPOSER_IPRESOLVE=4 composer install --ignore-platform-reqs --optimize-autoloader as described in the composer troubleshooting docs fixed the errors for me where many, many other solutions did not work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests