WSL: Unable to open any PORT in bash

I use sudo /usr/sbin/sshd -d -p 222 to set up ssh server, it seems it work fine.

root@kylin:~# sudo /usr/sbin/sshd -d -p 222
debug1: sshd version OpenSSH_7.2, OpenSSL 1.0.2g  1 Mar 2016
debug1: private host key #0: ssh-rsa SHA256:n3TQlnEiwWtPiOVqQnclmSZgI6DwpuqkzNQwSTp6Qqc
debug1: private host key #1: ssh-dss SHA256:hQ3FMTjSMSdLIpnuhc0AFc34Vw8y8ELLI3syKBbt7Yk
debug1: private host key #2: ecdsa-sha2-nistp256 SHA256:h3gvZq4ENKxOO3xYtJCbJYJu99hZsl41UKRZy9/ICew
debug1: private host key #3: ssh-ed25519 SHA256:WYZhx5y+qlwqLgMw1gx4e+T09pfy23URzwQElOHQ2aw
debug1: rexec_argv[0]='/usr/sbin/sshd'
debug1: rexec_argv[1]='-d'
debug1: rexec_argv[2]='-p'
debug1: rexec_argv[3]='222'
debug1: Set /proc/self/oom_score_adj from 0 to -1000
debug1: Bind to port 222 on 127.0.0.1.
Server listening on 127.0.0.1 port 222.

I was refused when I login by ssh,

root@kylin:~# ssh -vvv root@127.0.0.1 -p 222
OpenSSH_7.2p2 Ubuntu-4ubuntu2.1, OpenSSL 1.0.2g  1 Mar 2016
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: resolving "127.0.0.1" port 222
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to 127.0.0.1 [127.0.0.1] port 222.
debug1: connect to address 127.0.0.1 port 222: Connection refused
ssh: connect to host 127.0.0.1 port 222: Connection refused

It seems the port 222 was not open.

  • Windows version

Microsoft Windows [版本 10.0.14965]

  • bash version

root@kylin:~# lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 16.04.1 LTS Release: 16.04 Codename: xenial

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Reactions: 9
  • Comments: 49 (10 by maintainers)

Most upvoted comments

After I install WSL, I did the following steps:

  1. Install Nodejs
  2. write a test web service by Nodejs
  3. start the web service, the output seems everything OK, and listening the port 3000
  4. open IE and navigation to http://127.0.0.1:3000 (Not work)
  5. Allow all TCP/UDP for Inbound / Outbound, try again (Not work)
  6. Disable windows default firewall and defender, try again (Not work)
  7. ----- no idea

Uninstall tencent TGP and restart. Works for me.

Thanks to: https://github.com/Microsoft/BashOnWindows/issues/1554

Did you solved this porblem , I also have the same ? could you tell me how to solved it ?@tianxiaxi

I dont have tencent. But around the time the problem first started, i was dabbling with VPNs. i have uninstalled all VPNs now but the problem is still there. Anyway to rest my networking?

@ChenYangShao did you installed tencent TGP ? uninstall it.

I have test some ports above 1024 which still not working. such as: 2222, 2345, 9999, 5678 …

For test propose, I set up a java web service and a nodejs web service, even if the the output seems fine, but still get connection refused.

It has been reasonably demonstrated that the issue of ports not listening is due to the TDI filter driver interference (follow up from here). I am marking this issue duplicate of #1554.

@MendesMartini Your solution didn’t work for me either (version 1703, build 15063.674). @taigadigital What did fix the problem was uninstalling the program “Networx” and restarting. Alternatively it sounds like upgrading to version 1709 solves this as well, though I haven’t tried it myself (found in this thread).

The above does not work.

Also tried:

  • Opening ports on my router.
  • Disabling Windows Firewall completely.
  • Disabling my AV (NOD32) completely.
  • All of the above simultaneously regardless of how stupid that is.

After a lot of troubleshooting I resolved uninstalling the Juniper Network Client; it does install a driver that break the networking inside bash.

I uninstall the update KB4016871 and reboot. Then I open the bash, get nginx & ssh work!

image

But can’t see any port in bash. image

I reinstall KB4016871, it still work.