I'm using Windows 10 and I have 2 servers running is WSL, one opens port 5000 and the other one opens port 6000 and I can verify that by running netstat -tlunp
:
$ netstat -tlunp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:6000 0.0.0.0:* LISTEN 86241/puma 6.4.0 (t
tcp 0 0 0.0.0.0:5000 0.0.0.0:* LISTEN 86424/puma 6.4.0 (t
From the Windows side, I can also verify the ports are open by running netstat -aon
:
> netstat -aon
Active Connections
Proto Local Address Foreign Address State PID
TCP 127.0.0.1:5000 0.0.0.0:0 LISTENING 31996
TCP 127.0.0.1:6000 0.0.0.0:0 LISTENING 31996
In both cases I removed irrelevant lines for brevity and privacy.
Both Chrome and Edge can connect to 5000 just fine, but can't connect to 6000. They both show me this error:
What could be the culprit?
I found some commands online to add port forwarding, open firewall ports. I tried the latter and it didn't work. What makes me uncomfortable though is why is 5000 going through. I can't find anything anywhere that will allow that, so just adding a different way to let 6000 go through feels messy.
I don't remember doing anything special to make 5000 work, but it's possible that there was some firewall autoconfiguration that asked me to allow it and I said yes, and now for some reason it's not triggering.
Some ports are considered unsafe by your browser as the browser error tells you (ERR_UNSAFE_PORT
). So this is a browser issue and not one with your WSL/Windows system or firewall. Consider using another port, e.g. 8000
.
Read this answer on superuser and linked resources for more details, why and which ports are blocked.