WSL binds all ports, lose network access: Unable to connect

2

I'm using WSL for some node development on a Windows 10 machine (build 1803). Inevitably, within a few hours of starting WSL, all ports on the system become bound. At this point, no new network connections open, and I effectively lose network access until I restart.

netstat -qn |findstr BOUND

This shows all TCP ports bound up to the max, such as:

 TCP    0.0.0.0:60755          0.0.0.0:0              BOUND

I've tried using ipconfig to reset the windows side adapter, killing all WSL processes, and a bunch of other things, but nothing unbinds the ports. I'd like to be able to use my computer without having to restart every few hours.

I was able to find an open issue with limited info: https://github.com/Microsoft/WSL/issues/2523 but no solutions or workarounds.

Any way to reset WSL or open the ports would be much appreciated!

adeebm

Posted 2019-01-27T23:12:50.617

Reputation: 21

1What process/processes is/are responsible? if you run: netstat -qno | find "BOUND", what is the PID (last column) and what does this map to in TaskManager/Tasklist.exe? – HelpingHand – 2019-01-27T23:31:08.283

It seems to be adb, part of a cli for the Expo project I have. I expect it to open connections, as it's for remote debugging. But killing it or even WSL as a whole doesn't release the ports. – adeebm – 2019-01-28T03:03:34.387

It is surprising that killing the process doesn't clean up. Can you run the following PowerShell command and link the results: get-nettcpconnection -state BOUND -OwningProcess ((Get-Process adb).ID)[0] | select LocalAddress, LocalPort, state Note: I've put the process in as adb is that correct? – HelpingHand – 2019-01-28T14:11:30.983

By randomly killing processes, I found that 'init' in 'Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs' seems to actually terminate WSL and release the ports. Thanks for pointing me in the right direction! – adeebm – 2019-01-30T00:38:33.380

Answers

3

Temporary fix: use the Task Manager to "End process tree" for adb, wslhost.exe, and wslbridge.exe. However, this kills WSL and anything running on WSL.

Permanent fix: it looks like this is a known WSL bug described on GitHub here and here, and Microsoft fixed it in Build 18890. However, as of May 2019, Build 18890 is well ahead of the stable builds of Windows, so you need to enroll in the Windows Insider Program to get it.

Josh

Posted 2019-01-27T23:12:50.617

Reputation: 131