WSL Networking
IP Addressing
- WSL2 uses a virtual NAT-based network adapter
- Each WSL distribution has its own IP address
- Access WSL from Windows via
localhost or the distribution's IP
- Find WSL IP:
hostname -I inside WSL
Port Forwarding
- WSL2 runs as a VM, so port access from Windows works automatically
- Access Windows services from WSL:
localhost or 127.0.0.1
- Forward Windows ports to WSL:
netsh interface portproxy (WSL1 only)
Network Modes
- WSL1: Integrated network - shares Windows IP, no port forwarding needed
- WSL2: Virtual machine - separate IP, better performance but requires port access setup
Useful Commands
hostname -I # Get WSL IP address
ip addr show # Detailed network info
ping <windows-ip> # Test connectivity to Windows
Troubleshooting
- Check if WSL VM is running:
wsl -l -v
- Restart networking in WSL:
sudo service networking restart
- Windows Firewall may block connections between WSL and Windows apps
Accessing Windows from WSL
/mnt/c/ mounts your C: drive
- Use Windows executables directly:
cmd.exe /c dir
- Access localhost Windows apps at
http://localhost:<port>