WSL: WSL2 HTTPS Connections Timeout

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

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Reactions: 24
  • Comments: 41

Most upvoted comments

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

4 years later, still an issue.

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.

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

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

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

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

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

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.

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.

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 🤡

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?

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). https://github.com/microsoft/WSL/issues/4698#issuecomment-814259640 Note that on my side mtu 1350 vEthernet (WSL)

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.