WSL Networking and Port Forwarding

Ummer FarooqUmmer Farooq
2 min read

Considering vLLM is running inside WSL, and we are trying to expose it to the Windows network.

Step 1: Confirm WSL Server Is Listening on 0.0.0.0

In your docker-compose or command, make sure vLLM is not bound to 127.0.0.1. It should be bound to all interfaces (0.0.0.0):

python3 -m vllm.entrypoints.openai.api_server --host 0.0.0.0 --port 8000

Also, confirm with:

netstat -tuln | grep 8000

Should show:

tcp 0 0 0.0.0.0:8000 0.0.0.0:* LISTEN

Step 2: Identify the WSL IP

Inside WSL, run:

ip addr | grep inet

You’ll see something like inet 172.22.x.x — that's the internal IP of your WSL instance. But this is not accessible from the outside.

Step 3: Set up Port Forwarding (From Windows Host to WSL2)

Since WSL2 is on a different virtual network, you need to forward ports from the Windows host to WSL.

Use PowerShell as Administrator on Windows and run:

netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=8000 connectaddress=WSL-IP connectport=8000

Replace WSL-IP with the IP from Step 2. You can also use localhost if you're sure the service is bound to 0.0.0.0 in WSL.

Example:

netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=8000 connectaddress=172.22.64.1 connectport=8000

Then enable the firewall rule:

netsh advfirewall firewall add rule name="vLLM Port 8000" dir=in action=allow protocol=TCP localport=8000

Step 4: Use Your Windows Machine’s Private IP

From another machine on your LAN, access your vLLM server using:

http://<your-windows-private-ip>:8000

You can find this by running on Windows CMD:

ipconfig

Look for the IPv4 Address under your active network adapter (e.g., 192.168.x.x).

Step 5: Verify from Another Device

Try this in your browser or with curl:

curl http://<windows-ip>:8000/v1/models

You should get a response from the vLLM server.

(Optional) Clean Up Forwarding Rules

To remove the proxy:

netsh interface portproxy delete v4tov4 listenport=8000 listenaddress=0.0.0.0

⚠️ Notes

  • If you're using Docker inside WSL2, ensure Docker is binding to 0.0.0.0, or use Docker’s ports section in docker-compose.

  • Windows Defender Firewall can block incoming traffic. Ensure the port is allowed

  • WSL2 still doesn’t support host bridging, so this proxying is a stable workaround.

0
Subscribe to my newsletter

Read articles from Ummer Farooq directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Ummer Farooq
Ummer Farooq