Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to access WSL2 localhost on Windows Host Browser #8691

Closed
1 of 2 tasks
Ankit1598 opened this issue Aug 5, 2022 · 7 comments
Closed
1 of 2 tasks

Unable to access WSL2 localhost on Windows Host Browser #8691

Ankit1598 opened this issue Aug 5, 2022 · 7 comments

Comments

@Ankit1598
Copy link

Ankit1598 commented Aug 5, 2022

Version

Microsoft Windows [Version 10.0.25169.1000]

WSL Version

  • WSL 2
  • WSL 1

Kernel Version

5.15.57.1

Distro Version

Ubuntu 20.04

Other Software

No response

Repro Steps

  1. Run any application in WSL that creates a server on a port(3000, 4000, etc) like React, Next, Nuxt, etc
  2. Try to access this server via http://localhost:3000

Expected Behavior

Application thats running on http://localhost:3000 in WSL, should be visible on the browser

Actual Behavior

Accessing through the IP address of eth0 with the port works. So i.e. http://localhost:3000/ or http://127.0.0.1:3000/ fail, but http://172.26.200.132:3000/ works.

This worked until this morning when I updated to the latest version (0.65.3.0).

Diagnostic Logs

WslLogs-2022-08-05_23-41-23.zip

$ ver
Microsoft Windows [Version 10.0.25169.1000]

$ wsl.exe --status
Default Distribution: Ubuntu-20.04
Default Version: 2
WSL version: 0.65.3.0
Kernel version: 5.15.57.1
WSLg version: 1.0.41
MSRDC version: 1.2.3213
Direct3D version: 1.601.0
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.25169.1000

@Ankit1598 Ankit1598 changed the title Unable to access WSL2 locahost on Windows Browser Unable to access WSL2 locahost on Windows Host Browser Aug 5, 2022
@Ankit1598 Ankit1598 changed the title Unable to access WSL2 locahost on Windows Host Browser Unable to access WSL2 localhost on Windows Host Browser Aug 5, 2022
@jadelily18
Copy link

having the exact same issue. It just appeared randomly this week and I have no clue why. I have to expose the Nuxt app to the network and connect manually to the ip in the browser :')

@AnkitC1598
Copy link

having the exact same issue. It just appeared randomly this week and I have no clue why. I have to expose the Nuxt app to the network and connect manually to the ip in the browser :')

Hey, I recently fixed my issue, can you just search Resource Monitor and check under Listening Ports if your port is being occupied by any other windows process. In my case svchost.exe was using that port and once I excluded that port for windows to use my server started working properly

@QAnders
Copy link

QAnders commented Sep 23, 2022

Sounds like the "Fast Startup issue... We are running into this from time to time where "localhost" stops working, sometimes out of the blue while working.
Even stranger localhost might work on some ports, but not on others...

First thing to do is turn off "Fast startup" from Power settings. Hit your Windows Start button and start typing “Change what…”
image

Now, click the UAC link to enable the settings, then deselect the “Turn on fast startup” (we want it OFF), save changes:
image

Next open a Powershell in Administrator mode, and execute:

New-NetFirewallRule -DisplayName "WSL" -Direction Inbound  -InterfaceAlias "vEthernet (WSL)"  -Action Allow

Now restart your computer...

@xairoo
Copy link

xairoo commented Apr 28, 2023

I tried so many things. Different versions, also converting from 2 to 1 and vice versa and so much more.

Nothing worked till I tried this in PowerShell:

net stop winnat
netsh int ipv4 set dynamic tcp start=49152 num=16384
netsh int ipv6 set dynamic tcp start=49152 num=16384
net start winnat

@openspaceranger
Copy link

@QAnders Is fast startup a Windows Server 2022 feature? The reason I ask is because I do not see that option and I'm supposedly an admin.

@fuhaiwei
Copy link

fuhaiwei commented Sep 29, 2023

I tried so many things. Different versions, also converting from 2 to 1 and vice versa and so much more.

Nothing worked till I tried this in PowerShell:

net stop winnat
netsh int ipv4 set dynamic tcp start=49152 num=16384
netsh int ipv6 set dynamic tcp start=49152 num=16384
net start winnat

It works

# List reserved ports
netsh int ipv4 show dynamicport tcp
netsh int ipv4 show excludedportrange protocol=tcp

Copy link
Contributor

This issue has been automatically closed since it has not had any activity for the past year. If you're still experiencing this issue please re-file this as a new issue or feature request.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants