WSL: Can't reach 127.0.0.1 outside WSL2 Build 22623.1180

Version

Windows 11 Insider Preview Build 22623.1180

WSL Version

  • WSL 2
  • WSL 1

Kernel Version

5.15.83.1-microsoft-standard-WSL2

Distro Version

Ubuntu 18.04

Other Software

No response

Repro Steps

Open console of wsl try to start angular project in wsl like: npm start

try to reach http://127.0.0.1:4200

error connection, impossible to reach

ERR_CONNECTION_REFUSED

Expected Behavior

Load the page from server

Actual Behavior

impossible to reach

Diagnostic Logs

No response

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 10
  • Comments: 29

Most upvoted comments

Issue present here as well. I have to restart my Nginx server to make it work for a few minutes, then it looses the connection again. I will try to downgrade to 1.0.3. @damchey , can you let me know how you did that?

Try the following (with admin privileges):

# Install a specific version, e.g. a downgrade
# Download msixbundle bundle from GitHub, then execute the following command
# https://github.com/microsoft/WSL/releases/tag/1.0.3
powershell Add-AppxPackage -Path .\Microsoft.WSL_1.0.3.0_x64_ARM64.msixbundle -ForceUpdateFromAnyVersion -ForceApplicationShutdown

I can reach 127.0.0.1, but I keep losing localhost. Just started today, build 22623.1180

This is still a highly disruptive issue in February 2024.

I had this .wslconfig file in my home dir:

[wsl2]
networkingMode=mirrored

I removed it and shutdown wsl. Now, I have access again.

Man… This is REALLY annoying.

In my Windows 11 environment, I can go days without issues - then * BAM * just have to keep killing/restarting WSL and/or rebooting some magical number of times (while patting my head and sticking my tongue out in the appropriate non-documented ritual) in order to get things back working again…

Can’t figure out a rhyme or reason - just sometimes port/network forward works and sometimes it doesn’t.

Concerning my problematic projects… I have several projects that I’m working on under WSL2… A couple/few Express APIs and a couple/few Angular UIs (which I’m serving using either nodemon or ‘ng serve’ based on their versions)… Sometimes everything just works - other times, 1 or 2 of the 4-6 projects I’m actively working on simply can’t be reached from Windows, while all of the other running Express APIs and Angular apps are accessible without issue in my host Windows instance… Adding a portproxy via netsh in Windows host seemingly makes no difference…

Each time I encountering this annoying issue, I wind up wasting an hour or two wading through the many similar issues in this repo, without any real explanation or solution - then I just resign to rebooting until everything works (sometimes it’s just 1 reboot and sometimes it’s 3 or so)… Sooooo much wasted time… I really do like the dev ergonomics under Windows with WSL2 * when it works * - but when it doesn’t, I find myself entertaining just abandoning this flow for a Mac or Linux dev box so I can quit wasting so much time trying to figure out why it randomly works sometimes and then randomly doesn’t others…

WSL version: 1.2.5.0 Kernel version: 5.15.90.1 WSLg version: 1.0.51 MSRDC version: 1.2.3770 Direct3D version: 1.608.2-61064218 DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp Windows version: 10.0.22621.1702

Same here. As another data point: wslhost.exe stops listening to ports from inside WSL2 after exactly one minute after restarting the service Running nginx on WSL2 (ports 80, 443) Restarting nginx from inside WSL2 brings back wslhost.exe to listening for one minute Same with internal PHP -S server, port 8080 or anything else really. They all continuously work and are reachable from within WSL2, just not from Windows.

Tried wsl --shutdown, re-installing, restoring as WSL backup, disabled Windows faststart, downgrading etc. Keeps stop listening.

Update: same as @dimafedotov “This solution WSL/issues/9508 works for me.”

Issue present here as well. I have to restart my Nginx server to make it work for a few minutes, then it looses the connection again. I will try to downgrade to 1.0.3. @damchey , can you let me know how you did that?

Download manual: https://github.com/microsoft/WSL/releases/download/1.0.3/Microsoft.WSL_1.0.3.0_x64_ARM64.msixbundle And double-click to file

This solution WSL/issues/9508 works for me. Excerpt:

$Package = Get-AppxPackage MicrosoftCorporationII.WindowsSubsystemforLinux -AllUsers 
Remove-AppxPackage $Package -AllUsers
Add-AppxPackage .\Microsoft.WSL_1.0.3.0_x64_ARM64.msixbundle

I had an error like this on the last command:

Add-AppxPackage : Cannot find path 'C:\WINDOWS\system32\Microsoft.WSL_1.0.3.0_x64_ARM64.msixbundle' because it does
not exist.

But Remove-AppxPackage has already done the job - new 1.10 WSL was removed, and seems like system switched to in-box old version (but it’s still WSL 2). Now everything works, and wslhost.exe continues to listen on ports. 👍🏻

Confirm this error. I’m try reinstall windows, and after update to 1.1.0.0 - wsl auto close port after 5-10 sec =(

Also intermittent for me. The connection will either be immediately refused upon attempting to load the npm start-run page, or it will start to fail after a few minutes of using it. I’ve never gotten it to work for more than a few minutes.

$ wsl.exe --version
WSL version: 1.1.0.0
Kernel version: 5.15.83.1
WSLg version: 1.0.48
MSRDC version: 1.2.3770
Direct3D version: 1.608.2-61064218
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22621.1192

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.1 LTS
Release:        22.04
Codename:       jammy

Same here, but intermittent. Sometimes works, sometimes doesn’t. Using Ubuntu 20.04 running PHP development server on port 8080.