Increasing net.ipv4.ip_local_port_range beyond the default WSL range causes localhost TCP connections to hang
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 33.7k
- Forks
- 1.8k
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 116
Description
### Windows Version
Microsoft Windows [Version 10.0.26200.8875]
### WSL Version
2.6.3.0
### Are you using WSL 1 or WSL 2?
- [x] WSL 2
- [ ] WSL 1
### Kernel Version
_No response_
### Distro Version
_No response_
### Other Software
_No response_
### Repro Steps
Changing net.ipv4.ip_local_port_range from the WSL default causes all localhost TCP connections to hang. This affects multiple applications (Redis, Python HTTP server, curl, nc) and is not specific to a single service.
The issue is reproducible and is resolved only after running wsl --shutdown.
1. Start a fresh WSL session.
2. Verify localhost connectivity.
$ redis-cli ping
PONG
3. Verify the default ephemeral port range.
$ cat /proc/sys/net/ipv4/ip_local_port_range
44620 48715
4. Change the ephemeral port range.
sudo sysctl -w net.ipv4.ip_local_port_range="44620 65535"
(or)
sudo sysctl -w net.ipv4.ip_local_port_range="32768 60999"
5. Test localhost connectivity again.
redis-cli ping
or
python3 -m http.server 8000
curl http://127.0.0.1:8000
The attached screenshot shows:
redis-cli ping and curl http://127.0.0.1:8000 working with the default ephemeral port range (44620 48715).
Both commands hanging after changing net.ipv4.ip_local_port_range to 10000 65535 or 32768 60999.
### Expected Behavior
Changing the ephemeral port range should not affect localhost TCP connectivity.
### Actual Behavior
redis-cli ping hangs indefinitely.
curl http://127.0.0.1:8000 hangs.
nc hangs.
ss -tanp shows connections remaining in SYN-RECV.
redis-server continues listening on 127.0.0.1:6379.
Running wsl --shutdown restores localhost connectivity.
### Diagnostic Logs
Diagnostic information
While redis-cli is hanging:
$ ss -tanp | grep 6379
LISTEN 127.0.0.1:6379
SYN-RECV 127.0.0.1:6379 127.0.0.1:xxxxx
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the WSL 2 behavior with /proc/sys/net/ipv4/ip_local_port_range, sysctl, redis-cli, curl, and ss -tanp. Compare localhost connectivity before and after changing the range, and use wsl --shutdown to confirm the reported reset; done means localhost TCP connections continue working after the change without requiring shutdown.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- linux
- Domain
- networking, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100