microsoft / microsoft/WSL

Increasing net.ipv4.ip_local_port_range beyond the default WSL range causes localhost TCP connections to hang

Open
#41,227 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature network wsl2
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:

Image

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.