linux command 'netstat' doesn't work on WSL on Build 14986
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$
Is there anyone who can help me ?
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.
@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
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.
@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.
@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.
@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.
@aseering
The default windows firewall and defender.
@aseering I have already uninstalled Tencent PC Manager, but WSL web services still do not work...
@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.1instead ofhttp://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 badproxy.pacfile 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.
@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.
@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?
-
After you start your
SimpleHTTPServer, can you open an elevated cmd prompt in windows and donetstat -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? -
Can you try the repro steps I posted in #1498 and note your observation?
-
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.
-
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
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:
-
Full reinstall of WSL.
- lxrun /unstinall /full /y
- lxrun /install
-
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.
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
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
Is netstat still not functional?
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
Same Problem
+1 netstat shows nothing