How can I fix port forwarding in WSL2 so my local server is accessible?
#1
I’m trying to set up a local development environment on my Windows machine using WSL2, but I keep hitting a weird networking issue where my local server isn’t accessible from my host browser. I’ve followed the basic guides and the distro is running fine, but I can’t seem to get the port forwarding to work consistently. Has anyone else dealt with this specific problem and figured out what step they might have missed?
Reply
#2
I ran into this too. the service inside WSL2 was only listening on 127.0.0.1, so from Windows nothing came through. I switched the dev server to bind to 0.0.0.0 and after that I could reach it from Windows at localhostTongueORT.
Reply
#3
Windows Defender Firewall was the sneaky blocker for me. I added an inbound rule for that port (and for the WSL2 profile), and after that the traffic started flowing.
Reply
#4
Have you tried binding to 0.0.0.0 in the app and then checking inside WSL with netstat to confirm it's listening on all interfaces? If it isn't, Windows won't forward.
Reply
#5
I kept chasing it and even blamed WSL for days, then a VPN client or corporate routing seemed to mess with things. When I paused the VPN for a while, it helped briefly but it wasn't stable.
Reply


[-]
Quick Reply
Message
Type your reply to this message here.

Image Verification
Please enter the text contained within the image into the text box below it. This process is used to prevent automated spam bots.
Image Verification
(case insensitive)

Forum Jump: