WSL: Devices within the LAN cannot access the network service running in WSL.
Windows Version
Microsoft Windows [Version 10.0.22631.2506]
WSL Version
2.0.7.0
Are you using WSL 1 or WSL 2?
- WSL 2
- WSL 1
Kernel Version
5.15.133.1
Distro Version
Ubuntu 22.04
Other Software
node v20.9.0
Repro Steps
- node run the script:
Details
const http = require('http');
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello, World!\n');
});
const port = 3001;
server.listen(port, () => {
console.log(`Server is running on port ${port}`);
});
- At this point, I’m trying to access the service from a device on the same LAN (my phone) by visiting
192.168.6.288:3001. The ip is Windows lan ip. And get no response
By the way, Accessing localhost:3001 in the computer’s browser yields a response.
If I run the script in windows, the LAN device can access.
Expected Behavior
Device in LAN can access
Actual Behavior
No response
Diagnostic Logs
.wslconfig:
[experimental]
autoMemoryReclaim=gradual
networkingMode=mirrored
dnsTunneling=true
firewall=true
autoProxy=true
sparseVhd=true
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 16
@Kutius did you set up Hyper-V firewall to allow inbound traffic to port 3001? If not, can you please try running the following command in an admin powershell windows, then try the scenario again?
New-NetFirewallHyperVRule -DisplayName “allow port 3001 inbound” -Direction Inbound -LocalPorts 3001 -Action Allow