i am using wsl ubuntu how do i allow my 0.0.0.0:8000 to access on another device same network?
✅ Step-by-Step Guide
1. Start your server in WSL bound to 0.0.0.0
Make sure your app is listening on all interfaces:
python manage.py runserver 0.0.0.0:8000 # Django example
# OR
flask run --host=0.0.0.0 --port=8000 # Flask
2. Find your Windows Host's IP on the LAN
WSL runs in a virtualized environment, so your actual network-facing IP belongs to Windows, not WSL.
Run this in Windows Command Prompt or PowerShell:
ipconfig
Look under the active adapter (e.g., "Wi-Fi" or "Ethernet") for your IPv4 address — it will look like 192.168.1.xxx.
Let’s say it’s 192.168.1.100.
3. Forward a port from Windows to WSL
You need to forward Windows port 8000 to WSL’s internal IP.
Get the WSL IP from Ubuntu:
ip addr | grep inet
Find something like inet 172.x.x.x — that's your WSL IP (e.g., 172.24.93.12).
Now, in Windows PowerShell (as Administrator), run:
example:
netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=8000 connectaddress=172.24.93.12 connectport=8000
netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=8000 connectaddress=172.28.192.105 connectport=8000
This sets up a port proxy so requests to Windows:8000 are forwarded to WSL:8000.
4. Allow Port 8000 in Windows Firewall
Run in PowerShell (as Admin) to allow access:
New-NetFirewallRule -DisplayName "WSL Port 8000" -Direction Inbound -LocalPort 8000 -Protocol TCP -Action Allow
5. Test Access From Another Device
Now, from another device on the same network, go to:
http://192.168.2.6:8000
(Replace 192.168.2.6 with your Windows IP.)
✅ Optional: Remove Proxy Later
To delete the forwarding rule later:
netsh interface portproxy delete v4tov4 listenport=8000 listenaddress=0.0.0.0
To check if a port is exposed (i.e., open and listening) on your machine — whether in WSL or on Windows — you can use the following methods depending on where you want to check:
1. Check Listening Ports (WSL/Linux side)
In your WSL terminal, run:
sudo lsof -i -P -n | grep LISTEN
Or:
netstat -tuln
Look for a line like:
tcp 0 0 0.0.0.0:8000 0.0.0.0:* LISTEN
- 0.0.0.0:8000 means the app is listening on all interfaces (good).
- If it's 127.0.0.1:8000, it's only bound to localhost — not accessible from outside.
🧰 2. Check Windows Port Proxy Rules (if forwarding WSL port)
In Windows PowerShell, run:
netsh interface portproxy show all
You'll see any port forwarding rules from Windows to WSL (e.g., 0.0.0.0:8000 → 172.x.x.x:8000).
🧪 3. Test Port Accessibility (from another device or locally)
From another device:
On another device on the same network, run:
Or open it in a browser.
curl http://192.168.2.6:8000
From the same machine:
You can also test with telnet (install it first if needed):
telnet 127.0.0.1 8000
If the port is open, you'll get a blank screen or some server response. If it's closed, it will say "Connection refused."
🔥 4. Scan for Open Ports (Windows)
In Windows PowerShell:
Get-NetTCPConnection -State Listen | Where-Object { $_.LocalPort -eq 8000 }
Or to list all listening ports:
Get-NetTCPConnection -State Listen