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

linux command 'netstat' doesn't work on WSL on Build 14986 #1488

Closed
Sixoloy opened this issue Dec 11, 2016 · 37 comments
Closed

linux command 'netstat' doesn't work on WSL on Build 14986 #1488

Sixoloy opened this issue Dec 11, 2016 · 37 comments

Comments

@Sixoloy
Copy link

Sixoloy commented Dec 11, 2016

I just update to Build 14986 and re-install my bash. I try to set up a HTTP server using node.js. Although I got a line says:
sixoloy@Sixoloy:/mnt/g/ffmpeg/win/bin$ sudo node server.js
[sudo] password for sixoloy:
Server running at port: 8899.

But I still can't visit my site. I typed 'http://localhost:8899' on my browser, and I got a refused connection. So I typed 'netstat -an' in my bash and found empty port information!
Here are the results I got:

Windows PowerShell
版权所有 (C) 2016 Microsoft Corporation。保留所有权利。

PS C:\WINDOWS\system32> bash
sixoloy@Sixoloy:/mnt/c/Windows/System32$ netstat -an
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags Type State I-Node Path

sixoloy@Sixoloy:/mnt/c/Windows/System32$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.1 LTS
Release: 16.04
Codename: xenial
sixoloy@Sixoloy:/mnt/c/Windows/System32$

@Sixoloy
Copy link
Author

Sixoloy commented Dec 14, 2016

Is there anyone who can help me ?

@aseering
Copy link
Contributor

aseering commented Dec 14, 2016

If you run ps -ax in the second shell, do you see node running?

Also, are you able to run other Web services? For example, python -m SimpleHTTPServer (which spins up a simple fileserver from its current directory)

Also, what Windows firewall program (if any) are you running? Some third-party firewalls cause trouble for WSL processes. They're slowly being updated to work properly with WSL.

@Sixoloy
Copy link
Author

Sixoloy commented Dec 17, 2016

@aseering I tried another Web server(SimpleHTTPServer) and also turn off the firewall. I still could not connect my website. It seems my WSL can not run any Web services properly although I can see the process running in ps -ax command...

bash:
sixoloy@Sixoloy:/mnt/c/Users/Administrator$ ps -ax
PID TTY STAT TIME COMMAND
1 ? Ss 0:00 /init
2 tty1 Ss 0:00 /bin/bash
15 tty1 S 0:00 python -m SimpleHTTPServer
16 tty2 Ss 0:00 /bin/bash
26 tty2 R 0:00 ps -ax

@tianxiaxi
Copy link

tianxiaxi commented Dec 19, 2016

I have the same problem. The output for ps -ax seems fine but got a connection refused message while connecting the web service.

BTY, I already have the firewall and Windows Defender closed before testing.

@aseering
Copy link
Contributor

@tianxiaxi -- what firewall program are you using?

Note that I am not asking whether you have turned that program off. That is not important. Some firewalls break WSL even when they are turned off.

@Sixoloy
Copy link
Author

Sixoloy commented Dec 20, 2016

@aseering windows built-in firewall and Tencent PC Manager. I don't want to uninstall my firewall program in case of being exposed to virus.

@aseering
Copy link
Contributor

@Sixoloy -- the Windows built-in firewall should be fine.

Regarding Tencent PC Manager -- I don't see any discussion of it (working or otherwise) on #475 (the ticket that tracks third-party firewall issues). You may be the first person to try running WSL under it and to post here about it.

I don't know whether Tencent is your problem, but it could be. The only way to know for sure would be to uninstall it and see whether that fixes your issue. You could then reinstall right after testing WSL; if you keep the Windows firewall in place, having only one firewall for a few minutes while you test should hopefully not be too big of a risk.

If the problem is Tencent, then Tencent will need to provide the fix: For security reasons, if a firewall says to not let a network connection through, then Windows needs to not let that connection through. WSL applications look very unusual (they are, after all, Linux binaries); some firewalls that don't know about WSL just block them to be safe. In that case, Tencent might already have a patch that adds WSL support; you could ask them.

@tianxiaxi
Copy link

@aseering

The default windows firewall and defender.

@Sixoloy
Copy link
Author

Sixoloy commented Dec 26, 2016

@aseering I have already uninstalled Tencent PC Manager, but WSL web services still do not work...

@aseering
Copy link
Contributor

@Sixoloy -- ah, good to know; that rules that out.

I'm not sure what else could be the cause. Someone on the WSL team might have an idea. But a few ideas on things to try or to check:

  • I don't suppose you've configured Windows Defender to block this type of local Web service? I assume not. I haven't tried but I assume it will honor your configuration (and block this traffic) if you do so.
  • What happens if you try http://127.0.0.1 instead of http://localhost? (The former should get connected directly by the TCP stack, I would assume; the latter could be broken by a bad hosts file in either Windows or Linux, maybe a bad proxy.pac file or other proxy configuration in Windows?; etc.)
  • There are native-Windows versions of node and Python; can you connect to a service that's launched using the same commands from Windows? (Trying to narrow down whether this is WSL-related.)
  • Also -- what happens if you launch the service and type something like curl http://127.0.0.1:8899 (or whatever appropriate port) into a second bash window? (I forget whether curl is installed by default; if not, you'll be prompted to install it.) Again, trying to find some narrower definition of where connectivity breaks.

@Sixoloy
Copy link
Author

Sixoloy commented Dec 26, 2016

@aseering Of course I can run those same commands perfectly on Windows.
When I run python -m SimpleHTTPServer on WSL and open another BASH, it shows as follows:

sixoloy@Sixoloy:/mnt/c/Users/Administrator$ ps -aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.0 0 0 ? Ss 2432 0:00 /init
sixoloy 2 0.0 0.0 0 0 tty1 Ss 2848 0:01 /bin/bash
sixoloy 1435 0.0 0.0 0 0 tty2 Ss 2848 0:00 /bin/bash
sixoloy 1447 0.0 0.0 0 0 tty1 S 2848 0:00 python -m Simplsixoloy 1448 0.0 0.0 0 0 tty2 R 2848 0:00 ps -aux
sixoloy@Sixoloy:/mnt/c/Users/Administrator$ curl http://127.0.0.1:8899
curl: (7) Couldn't connect to server
sixoloy@Sixoloy:/mnt/c/Users/Administrator$ curl http://localhost:8899
curl: (7) Couldn't connect to server


When I type 'netstat', it shows nothing on the screen. I suppose there is something wrong related with net ports on my WSL.

@sunilmut
Copy link
Member

@Sixoloy - Sorry for the delay here. Just FYI that the netstat utility in WSL is currently not functional. We are aware of that and are looking into it.

Can you try couple of things and post back your experience?

  1. After you start your SimpleHTTPServer, can you open an elevated cmd prompt in windows and do netstat -a | find "<port where SimpleHTTPServer is expected to be listening>" and share the output of that? Do you see anyone listening on the designated port?

  2. Can you try the repro steps I posted in Unable to open any PORT in bash #1498 and note your observation?

@Sixoloy
Copy link
Author

Sixoloy commented Dec 30, 2016

  1. I ran SimpleHTTPServer in my WSL and I did 'netstat -a | find "8080" in Windows. Unfortunataly it showed nothing so I think the server is not running actually.

  2. After I installed Apache2 and type start, it showed as follow:

sixoloy@Sixoloy:/mnt/g/ffmpeg/win/bin$ sudo /etc/init.d/apache2 start

  • Starting Apache httpd web server apache2 *
  • The apache2 configtest failed.
    Output of config test was:
    apache2: ../sysdeps/posix/getaddrinfo.c:2603: getaddrinfo: Assertion `IN6_IS_ADDR_V4MAPPED (sin6->sin6_addr.s6_addr32)' failed.
    Aborted (core dumped)
    Action 'configtest' failed.
    The Apache error log may have more information.
    sixoloy@Sixoloy:/mnt/g/ffmpeg/win/bin$ sudo /etc/init.d/apache2 status
  • apache2 is not running

@sunilmut
Copy link
Member

Thanks @Sixoloy. @lefty-kreouzis had a very similar problem in #1554. For him, a reinstall of Windows did the trick. Not something I would want to recommend, but I am out of ideas otherwise. You can try:

  1. Full reinstall of WSL.

    • lxrun /unstinall /full /y
    • lxrun /install
  2. Reinstall of Windows.

Please do backup your data prior to any reinstall. Not sure why apache2 is not working for you, but let's take that separately.

@rishavs
Copy link

rishavs commented Jun 15, 2017

same problem. cant connect to my web server on wsl from windows.
cant even connect to my wsl web server from wsl itself. says 'failed. connection refused'

Things i have tried so far;
Reinstall WSL
switch off windows firewall. Switch off Bitdefender Antivirus

@lzskyline
Copy link

Same problem too.
It's says: "connection refused" when i was using Redis-cli to connect itself
I checked the running process using command: ps -ax
Redis-server is in there and seems not any problem.
But when I use netstat to check my port, it's return EMPTY.
May it's a bug. I think.
By the way, I'm only use the built-in firewall

@imrelaxed
Copy link

Is netstat still not functional?

@gkenaley
Copy link

gkenaley commented Sep 5, 2017

I have the same problem (servers don't work/netstat shows nothing):
root@BULLITT:/home/wruser# ps ax | grep -i streaming
115 ? Ss 0:00 /usr/local/sbin/DarwinStreamingServer
117 ? Sl 0:00 /usr/local/sbin/DarwinStreamingServer
116 ? Ss 0:00 /usr/bin/perl /usr/local/sbin/streamingadminserver.pl
131 tty1 S 0:00 grep --color=auto -i streaming
root@BULLITT:/home/wruser# netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name

@hybridtechie
Copy link

Same Problem

@sgrebnov
Copy link

+1 netstat shows nothing

@xiangfei200
Copy link

same problem too

@Katapeltes
Copy link

same problem with the built-in firewall.

@sweetIan
Copy link

same problem

@ryanerwin
Copy link

+1

netstat -tl isn't working on the most recent insider release... also note netstat is deprecated, so I tried using ss -a but that didn't work either...

sudo ss -a                                                                                                                                 
Netid  State      Recv-Q Send-Q                     Local Address:Port                                      Peer Address:Port
                 
Cannot open netlink socket: Protocol not supported
                                                                                            
nl     UNCONN     0      0                                   rtnl:4                                                     *                     
nl     UNCONN     0      0                                   rtnl:5                                                     *                     
Cannot open netlink socket: Protocol not supported                                                                                            
Cannot open netlink socket: Protocol not supported                                                                                            
Cannot open netlink socket: Protocol not supported                                                                                            
Cannot open netlink socket: Protocol not supported                                                                                            
Cannot open netlink socket: Protocol not supported 

@e-belair
Copy link

Hi, I think i've the same problem
I've installed Firebird in wsl
After started the service, i can't connect to the server
So i openned the port in firewall or totaly disabled firewall .... nothing change
netstat -an show nothing
ps -aux wont show firebird running
But i can see apache running and access web server from browser

@pcnetzwerke
Copy link

Hi, I have the same problem, I think.
Try to run sshd in wsl.
netstat -an showing nothing
Win10 Firewall is disabled

@tangyouwo
Copy link

+1 netstat shows nothing
and when tried curl the server ,
failed. connection refused

@rishavs
Copy link

rishavs commented Nov 2, 2017

A possible solution may be here;
#1554

@ryanerwin
Copy link

@tangyouwo the solution @rishavs provided is probably relevant to you.

looks like there are two issues... one is people unable to connect to TCP or UDP services due to the software firewall embedded in their Linux distribution.

a separate issue is that netstat -tl or ss -a still don't list processes that are listening for connections, typically generating the error:

Cannot open netlink socket: Protocol not supported

@therealkenc
Copy link
Collaborator

Yes this issue is disjointed because the title doesn't match the contents of the OP. Tencent is #475 #1553 et al. Netstat is #2249 (because catch-all #2084 was closed).

@fatfatson
Copy link

after uninstall Tencent software, nginx tcp port could be connected, but netstat -ln still show nothing...

@therealkenc
Copy link
Collaborator

As it states above, netstat is #2249 not Tencent.

@amao12580
Copy link

netstat,lsof still not work!

2018年10月13日

@Rowing0914
Copy link

netstat not working,,, come on.
when it'll be fixed??

@nephewtom
Copy link

yep, not working... LOL!

@morgan-greywolf
Copy link

morgan-greywolf commented Dec 24, 2018 via email

@knoxcard2
Copy link

apt install net-tools

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

No branches or pull requests