ncat closes connection prematurely on WSL2 unless --keep-open is specified
Windows Version
Microsoft Windows [Version 10.0.26200.7019]
WSL Version
2.6.1.0
Are you using WSL 1 or WSL 2?
- [x] WSL 2
- [ ] WSL 1
Kernel Version
6.6.87.2-microsoft-standard-WSL2
Distro Version
Ubuntu 24.04
Other Software
Ncat: Version 7.94SVN ( https://nmap.org/ncat )
Repro Steps
- Run
ncat -v -l 12345in one terminal. - Run
ncat -v 127.0.0.1 12345in another terminal. - Observe that the first terminal correctly shows
Ncat: Connection from 127.0.0.1:46128.or similar. - Try to send
hellofrom the second terminal (enterhelloand press Enter). - Observe that the second
ncatcommand terminated with errorNcat: Connection reset by peer..
- If you try the same with extra option
--keep-openin the first terminal, it all works as expected. - If you try the same with the first terminal using a WSL1 distro, it all works as expected.
- If you try the same with
ncinstead ofncat, it all works as expected.
Note: I am using mirrored network mode.
Expected Behavior
hello can be sent and is received on the other end.
Actual Behavior
Connection dies with Ncat: Connection reset by peer. and hello is not received on the other end.
Diagnostic Logs
Networking logs: WslNetworkingLogs-2025-11-17_12-54-48.zip
Packet captures using Wireshark inside WSL2 on loopback0:
- Port 33001: Broken
ncatwithout--keep-openon WSL2 - Port 33002: Working
ncatwith--keep-openon WSL2 - Port 33003: Working
ncatwithout--keep-openon WSL1 - Port 33004: Working
ncon WSL2 ncat_tests2.zip
No logs.etl found in the archive. Make sure that you ran collect-wsl-logs.ps1 as administrator and that the logs.etl file is in the archive.
Diagnostic information
Multiple log files found, using: https://github.com/user-attachments/files/23581844/WslNetworkingLogs-2025-11-17_12-54-48.zip
.wslconfig found
Detected appx version: 2.6.1.0
optional-components.txt not found
No logs.etl found in archive.
Error while parsing the logs. See action page for details
I don't know about any log.etl file, this is the ZIP your script from the wiki produced, as-is (yes it was run as admin). Please advise.
/logs
Diagnostic information
.wslconfig found
Detected appx version: 2.6.1.0
Thank you. I can see in the logs that mirrored networking is enabled. @CatalinFetoiu : Could you have a look ?