WSL icon indicating copy to clipboard operation
WSL copied to clipboard

Cannot connect to Internet via https

Open evil-shrike opened this issue 9 years ago • 18 comments

UPDATE: initially the issue was named "Cannot install dotnet sdk from https://packages.microsoft.com". It was the case I encountered with the problem. But actually I'm having problems with connecting to any https site.

Windows Version 10.0.16299.64 WSL Ubuntu (uname -a): Linux 4.4.0-43-Microsoft #1-Microsoft Wed Dec 31 14:42:53 PST 2014 x86_64 x86_64 x86_64 GNU/Linux

I'm trying to install dotnet sdk as described here - https://www.microsoft.com/net/learn/get-started/linuxubuntu

My machine is behind a corporate proxy, so I have exported http_proxy and https_proxy. I can curl/wget any pages, so example: curl https://packages.microsoft.com/ returns me some html. I can install a pacakge via apt-get:

sudo apt-get upgrade curl

So in general the system is healthy and can connect to internet.

But it seems that apt-get cannot install a package via https. After I added a new source for dotnet "https://packages.microsoft.com/repos/microsoft-ubuntu-trusty-prod trusty main" and run sudo apt-get update it stuck on that source (https://packages.microsoft.com):

Err:9 https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod xenial InRelease Failed to connect to packages.microsoft.com port 443: Connection refused

I also tried to force IPv4 connection (sudo apt-get -o Acquire::ForceIPv4=true update) but it didn't change anything.

I have no any antivirus installed.

I run sudo strace -o aptget.txt -ff apt-get -o Acquire::ForceIPv4=true update but it creates so many files: Not sure which one to share: image

evil-shrike avatar Nov 24 '17 17:11 evil-shrike

curl the whole link as shown in that tutorial curl https://packages.microsoft.com/keys/microsoft.asc .

Biswa96 avatar Nov 24 '17 18:11 Biswa96

@Biswa96 sure I did, it returns the key.

evil-shrike avatar Nov 24 '17 18:11 evil-shrike

strace -ff command 2> output.txt creates a single file you can upload on pastebin/gist.

onomatopellan avatar Nov 24 '17 18:11 onomatopellan

root@:~# sudo strace -ff "apt-get update" 2> output.txt
root@:~# cat output.txt
strace: Can't stat 'apt-get update': No such file or directory

?

evil-shrike avatar Nov 24 '17 19:11 evil-shrike

sorry, without the quotes sudo strace -ff apt-get update 2> output.txt

onomatopellan avatar Nov 24 '17 19:11 onomatopellan

Ok, here's the log - https://gist.github.com/evil-shrike/c2c7e8ea5abc9da8882149001e927461

evil-shrike avatar Nov 24 '17 19:11 evil-shrike

So, no ideas?

evil-shrike avatar Nov 29 '17 15:11 evil-shrike

It's got a lot of EINVALs on connect. Can't tell you why, and there are too many open (and closed) ipv6 issues to find if there has been a similar report. Perhaps do the strace with Acquire::ForceIPv4=true so at least we can avoid the ipv6 noise.

[pid  1313] connect(5, {sa_family=AF_INET6, sin6_port=htons(443), inet_pton(AF_INET6, "2600:9000:2099:cc00:1f:6523:6040:93a1", &sin6_addr), sin6_flowinfo=0, sin6_scope_id=0}, 28) = -1 EINVAL (Invalid argument)

therealkenc avatar Nov 29 '17 18:11 therealkenc

Ok, this is log from sudo strace -ff apt-get -o Acquire::ForceIPv4=true update 2> output.txt - https://gist.github.com/evil-shrike/f7e424b7fcc3ab68d35b44fda1a5ea79

evil-shrike avatar Nov 29 '17 18:11 evil-shrike

UPDATE:

  • I disabled Firewall
  • I run WSL as Admin
  • I switched off IPv6 in Windows Network Center
  • I set up both http_proxy and https_proxy env vars in .bashrc
root@SDOROGIN-NEW:~# wget http://microsoft.ru
--2017-12-04 13:06:59--  http://microsoft.ru/
Resolving proxy.company (proxy.company)... 10.1.0.167, 10.1.0.166
Connecting to proxy.company (proxy.company)|10.1.0.167|:8000... connected.
Proxy request sent, awaiting response... 301 Moved Permanently
Location: https://microsoft.ru/ [following]
--2017-12-04 13:06:59--  https://microsoft.ru/
Resolving microsoft.ru (microsoft.ru)... 191.239.213.197, 104.40.211.35, 23.96.52.53, ...
Connecting to microsoft.ru (microsoft.ru)|191.239.213.197|:443... failed: Resource temporarily unavailable.
Connecting to microsoft.ru (microsoft.ru)|104.40.211.35|:443... failed: Resource temporarily unavailable.
Connecting to microsoft.ru (microsoft.ru)|23.96.52.53|:443... failed: Resource temporarily unavailable.
Connecting to microsoft.ru (microsoft.ru)|23.100.122.175|:443... failed: Resource temporarily unavailable.
Connecting to microsoft.ru (microsoft.ru)|104.43.195.251|:443... failed: Resource temporarily unavailable.
Retrying.

--2017-12-04 13:08:45--  (try: 2)  https://microsoft.ru/
Connecting to microsoft.ru (microsoft.ru)|191.239.213.197|:443... ^C
root@SDOROGIN-NEW:~# echo $http_proxy
http://proxy.company:8000
root@SDOROGIN-NEW:~# echo $https_proxy
http://proxy.company:8000

evil-shrike avatar Dec 04 '17 10:12 evil-shrike

have you solve this problem @evil-shrike ? I've got similar issue, i can ping etc etc but when use wget here the result

wget http://archive.ubuntu.com
--2018-06-04 20:42:04--  http://archive.ubuntu.com/
Resolving archive.ubuntu.com (archive.ubuntu.com)... 91.189.88.161, 91.189.88.149, 91.189.88.152, ...
Connecting to archive.ubuntu.com (archive.ubuntu.com)|91.189.88.161|:80... connected.
HTTP request sent, awaiting response... No data received.
Retrying.

Uninstall and reinstall WSL feature, check Disable all firewall and antivirus check

wicaksono avatar Jun 04 '18 13:06 wicaksono

@wicaksono Nope. Still not working (with latest April Update). But you have issues with connecting via http, probably it's another problem (I have no problems with http, only with https).

evil-shrike avatar Jun 04 '18 14:06 evil-shrike

I have the same problem. When I restart my computer without Kaspersky antivirus, everything works fine, but with the protection active, the connections then fail...

dhyannirav avatar Aug 30 '18 18:08 dhyannirav

Facing the same issue across all my wsl installations, started a couple of days ago and has given me hell ever since, I'm running kaspy too, but I've disabled protection (not restarted) and tried and still apt update or git pull fails

bkr32 avatar Sep 09 '18 19:09 bkr32

I'm also using Kaspersky and when closing the Antivirus It's immediately works, no restart needed (pausing the protection however didn't fix the issue..only full exit). When I'll have the time I will try to find out how to keep kasp working and also be able to use https on the WSL, maybe an exception rule for application or port will do the bypass.

I think that it is fair to say that Kaspersky has something to do with that issue..

For easy counting of how many Kaspersky users have this problem, please respond with 👀 if you have this issue and you are also using Kaspersky.

Ron-Burg avatar Jan 20 '19 20:01 Ron-Burg

I'm facing the same issue, thx google sending me here and thx to @Ron-Burg indicated the root cause. I've figured out a easier way to workaround this issue without shutting down Kasp:

  1. Open Kaspersky AV main interface and click on Config(the gear icon)
  2. Open last tab called "Additional" (Where contains settings for Update, Threat and Exclusions, Self Defence...etc.)
  3. In that tab's pane click "Network"
  4. Depends on your Kasp AV version, there will be a setting that's related to "Scan encrypted connections", Disable that or select "do not scan encrypted connections".

Immediately WSL's outbound connectivity to HTTPS/SSL endpoints will work. Hope that helps to others coming to that page...

hyha avatar Jan 21 '19 15:01 hyha

Yes! That works for me to, even without exiting Kaspersky complitly. I think that it has somthing to do with the "Man In The Middle" approach of the antivirus while trying to decrypt the ssl communication. (Somthing like that: https://www.youtube.com/watch?v=M9Oe8yRaooE)

Is there any reason why Kaspersky would not be able to decrypt the traffic comming from the WSL?

Ron-Burg avatar Jan 21 '19 21:01 Ron-Burg

This issue has been automatically closed since it has not had any activity for the past year. If you're still experiencing this issue please re-file this as a new issue or feature request.

Thank you!