Skip to content

fix(expose): skip Windows/Hyper-V excluded port ranges on WSL2 - #122

Merged
gustavobertoi merged 2 commits into
mainfrom
fix/expose-wsl2-excluded-ports
Jul 10, 2026
Merged

fix(expose): skip Windows/Hyper-V excluded port ranges on WSL2#122
gustavobertoi merged 2 commits into
mainfrom
fix/expose-wsl2-excluded-ports

Conversation

@gustavobertoi

Copy link
Copy Markdown
Contributor

On WSL2 + Docker Desktop, Windows and Hyper-V dynamically reserve TCP port ranges (netsh excludedportrange), and those ranges move on every Windows reboot. The host-port allocator only bind-tested inside the Linux distro, which cannot see the Windows-side reservation, so it would hand out a port (e.g. minio's 59000) that Docker Desktop's Windows-side forward then rejects with:

ports are not available: exposing port TCP 127.0.0.1:59000 ->
127.0.0.1:0: /forwards/expose returned unexpected status: 500

FreeHostPort now queries netsh.exe on WSL2, treats excluded ranges as unavailable during allocation, and releases a persisted port that has fallen into a newly-excluded range so it re-allocates a usable one.

gustavobertoi and others added 2 commits July 9, 2026 22:14
On WSL2 + Docker Desktop, Windows and Hyper-V dynamically reserve TCP
port ranges (netsh excludedportrange), and those ranges move on every
Windows reboot. The host-port allocator only bind-tested inside the
Linux distro, which cannot see the Windows-side reservation, so it would
hand out a port (e.g. minio's 59000) that Docker Desktop's Windows-side
forward then rejects with:

  ports are not available: exposing port TCP 127.0.0.1:59000 ->
  127.0.0.1:0: /forwards/expose returned unexpected status: 500

FreeHostPort now queries netsh.exe on WSL2, treats excluded ranges as
unavailable during allocation, and releases a persisted port that has
fallen into a newly-excluded range so it re-allocates a usable one.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@gustavobertoi
gustavobertoi merged commit 0e38a44 into main Jul 10, 2026
4 checks passed
@gustavobertoi
gustavobertoi deleted the fix/expose-wsl2-excluded-ports branch July 10, 2026 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant