Skip to content

IPv4 loopback (127.0.0.1) port forwarding fails after wsl --shutdown while IPv6 (::1) continues to work #41196

Description

@DragonBishop

Windows Version

Microsoft Windows [Version 10.0.26200.8875]

WSL Version

2.7.10.0

Are you using WSL 1 or WSL 2?

  • WSL 2
  • WSL 1

Kernel Version

6.18.33.2-2

Distro Version

Ubuntu 26.04 LTS

Other Software

k3s version v1.36.2+k3s1 (01b6f04a)
go version go1.26.4

.wslconfig settings:

[wsl2]
dnsTunneling=true
autoProxy=true

[experimental]
autoMemoryReclaim=gradual
sparseVhd=true

I don't use mirrored networking because it clashes with cilium in my k3s cluster.

Repro Steps

  1. From WSL, cleanly stop any services listening on the port in question. I was running a k3s cluster with port 6443.
  2. Run Powershell as Admin: wsl --shutdown
  3. Reopen a WSL terminal (fresh VM boot).
  4. WSL: start the service back up (I use a .sh script to manually wind up or down my cluster safely)
  5. WSL: confirm the API server is listening: sudo ss -tlnp | grep 6443
  6. WSL: confirm the cluster is healthy: kubectl get nodes
  7. Windows PowerShell: Test-NetConnection -ComputerName localhost -Port 6443
  8. Windows PowerShell: Test-NetConnection -ComputerName 127.0.0.1 -Port 6443

Expected Behavior

Both localhost and 127.0.0.1 should reach the service listening inside the fresh WSL2 VM, since WSL2's default NAT networking mode forwards both.

Actual Behavior

localhost (resolves to ::1, IPv6) connects successfully. 127.0.0.1 (IPv4) fails to connect, even though step 5 confirms the target process is listening on the port.

Diagnostic Logs

Evidence

Step 5 confirms the process is listening:

$ sudo ss -tlnp | grep 6443
LISTEN 0 4096 *:6443 : users:(("k3s-server",pid=449,fd=12))

Step 6 confirms the cluster/node is healthy:

$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
portis Ready control-plane 9d v1.36.2+k3s1

Step 7 localhost (IPv6) succeeds:

PS C:\Users\dragonbishop> Test-NetConnection -ComputerName localhost -Port 6443
ComputerName : localhost
RemoteAddress : ::1
RemotePort : 6443
InterfaceAlias : Loopback Pseudo-Interface 1
SourceAddress : ::1
TcpTestSucceeded : True

Step 8 127.0.0.1 (IPv4) fails:

PS C:\Users\dragonbishop> Test-NetConnection -ComputerName 127.0.0.1 -Port 6443
WARNING: TCP connect to (127.0.0.1 : 6443) failed
ComputerName : 127.0.0.1
RemoteAddress : 127.0.0.1
RemotePort : 6443
InterfaceAlias : Loopback Pseudo-Interface 1
SourceAddress : 127.0.0.1
PingSucceeded : True
PingReplyDetails (RTT) : 0 ms
TcpTestSucceeded : False

In addition, Windows Headlamp fails to connect to the cluster despite having access to the same .kubeconfig that I use to mount my devcontainer in WSL, which I can confirm works for applications within WSL2.

I experimented with a full computer restart, and checking to see if a VPN was causing the problem, neither of which had any impact.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-investigationlikely actionable and/or needs more investigationnetworkwsl2Issue/feature applies to WSL 2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions