-
Notifications
You must be signed in to change notification settings - Fork 809
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
WSL2 localhost access is intermittent with stuck connections #4340
Comments
Confirmation this is a TCP keep alive issue
Resolves the issue The setting But this change shouldn't be necessary and has other implications |
10.0.18945.1001 (I am using WSL 2 mode) |
Phew thought I was going crazy! It's such a specific narrow problem... I'm sure it's WSL 2 at fault here, as accessing over the WSL eth0 IP the problem goes away, so it's somehow related to whatever network trickery they use to get localhost working |
Facing the same issue with apache. Windows build : 10.0.18945.1001 with Ubuntu on WSL2 fresh install. Accessing a website on localhost works only once in two. Like benc-uk with nodejs. Turning off KeepAlive in apache conf resolve the issue. |
Thanks Seeing the same "one request in every two" weird behavior |
Thanks for posting. I will dig into this. |
I'm facing a similar issue, using NodeJs (v12.4.0) it only works once after that I get ERR_CONNECTION_REFUSED, the same in my Elixir(1.9.1)-Phoenix project. |
Just confirms it happens with Java Tomcat too |
I've been experiencing this issue with node.js servers as well. Thanks @benc-uk for mentioning the stopgap solution with For those using devServer: {
before: function(app, webpackServer) {
// We override the listen() function to set keepAliveTimeout.
// See: https://github.com/microsoft/WSL/issues/4340
// Original listen(): https://github.com/webpack/webpack-dev-server/blob/f80e2ae101e25985f0d7e3e9af36c307bfc163d2/lib/Server.js#L744
const { listen } = webpackServer
webpackServer.listen = function(...args) {
const server = listen.call(this, ...args)
server.keepAliveTimeout = 0
return server
}
}
} |
I'm not sure, but my problem has been softened with this: |
Thanks @karthikv var server = require('http').createServer(app);
server.keepAliveTimeout = 0; // This is a workaround for WSL v2 issues
server.listen(port); Which I'm using rather than the more normal I'd rather not have to workaround this in all my code, and I'm sure it has performance implications |
I am facing the same problem with rails application. Reloading problem. This keepaliveTimeOut is node specific. Anything that needs to be done for a rails app? I did try persistent_timeout 0 for puma configuration but not working. |
For Rails with Puma, I'm using the eth0 IP address without problem. Localhost works for a few requests and then stops. The IP address works pretty well so far. Edit: Actually, IP address almost works great. I have a subdomain I need to access in my app, `foo.localhost:3000' works nicely in Chrome (except that localhost is now completely broken). Now I'm manually changing the Windows HOSTS file (\Windows\System32\drivers\etc\hosts for reference) to make this work |
@tomfakes, try this: https://github.com/shayne/wsl2-hacks |
I just upgraded to 18956 and my 'localhost' access from Windows to Ubuntu seems to be much more reliable so far |
I also updated to 18956, but didn't see any changes, this problem still exists. |
Confirming the same issue using flask and docker-compose. Sporadic connection from localhost and interestingly no connection at all when I try 127.0.0.1. Both domains work fine on docker desktop. |
I've mostly switched to using named hosts in the Windows hosts file. This week I'm working on multiple cross-domain apps, so having a broken localhost actually works to my advantage. But for short tests, localhost is more reliable this version than it was in 18950. |
still breaks in 18956 |
@benhillis I've just upgraded to If I go directly to the IP of the guest, A picture is worth a thousand words: |
@FlipperPA - Could you give me a set of command line repro steps I could try? Also would you mind taking a trace? https://github.com/microsoft/WSL/blob/master/CONTRIBUTING.md#8-detailed-logs |
Well something weird for me on 19018.1. |
@benhillis @stefankummer I'll see if I can come up with a solid repro, but it is now working... which is especially weird, because I had tried restarting Ubuntu 18 and restarting all of Windows before posting above. I'll report back if I can get it to happen again! |
Serving files for me (express or http.server, doesn't matter) on 19030 is extremely slow on localhost (you can see images charging like with old 56k modems). |
Just updated to 19536 and this seems broken again I thought we had this one nailed! :( |
I think my latest issue is actually this #4769 If I "reboot" WSL then then first connection/service binding works, all other services after the first don't work |
@benc-uk - fix is inbound. |
Seems like I have similar issue with Apache in Docker (for WSL 2) on build 19041.21 (slow insider ring) When I replaced that with the WSL IP, everything started working again. |
Port forwarding on build 19541.1000 (slow insider channel) is also broken on first boot. When I issue |
Closing for now as #4769 has been closed |
Hi, It has vhost issue as explained below : I have two projects Laravel (var/www/html/laravel/..) laravel.dev.config In hosts file (/etc/hosts) I added below lines : Now in browser when I type "localhost", it loads default Apache page. Scenario 1 : Scenario 2 : Scenario 3 : I am ready to screen share if anyone is ready to help. |
I am also having this issue still. I tried stopping and restarting WSL like @khuongduybui mentioned and now it works with Rails. This always seems to happen after I shut down the computer and come back to it. |
I've been having this issue since I installed docker-desktop |
@Himakar-PV Its not related to this issue. You need to setup your hosts in Windows |
I see this issue too. |
Same here on same version, happening on PHP (73, 74, 80) vanilla built-in webserver, bound to 127.0.0.1 or 0.0.0.0 port 8000 (or anything)
|
The issue seems to have gone away again after upgrading to 22543 Edit: nope, still happening |
Happening to me as well.
|
@clovis1122 I have determined this is a bug in the latest version of WSL, the one available via the Microsoft Store. But the good news is, an older version is available - the one bundled with Windows, - and it does not have this issue. To install the bundled (aka "in-box") version, you need to (1) explicitly uninstall the Microsoft Store version, and then (2) You'll know you got the right version if it doesn't have a
|
Just noting that this is still an issue. PS C:\WINDOWS\system32> wsl --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.1194``` |
Yes it just came back in the latest Windows update on Dev channel for me. |
Edit: Downgrade to 1.0.3: #9508 |
@illepic, @khuongduybui: |
Please fill out the below information:
Your Windows build number: 10.0.18945.1001 (I am using WSL 2 mode)
What you're doing and what's happening:
Opening a URL served via a Node.js app using localhost, from a Windows browser results in page/URL never loading. It will spin indefinitely trying to load, rather than getting an error that site/page can not be found
Hitting stop and then refresh in browser will result in page loading OK
Page will continue to load OK, if you send requests to it quickly, if you wait a few seconds the problem will return and the URL and site will never load
I have verified the following:
- It only happens with Node.js, I've tried Python, .NET Core and Golang web apps with out problem
- Problem only happens with localhost, if I use the IP of
eth0
and access the app that way, I get no issues- It affects Node.js 8.x and 10.x, presumably other versions too
- I've tried with Debian 9.7 and Ubuntu 18.04 distros and both have the same problem
- It makes no difference what port I use
- It makes no difference what browser is used (Edge, Chrome, Firefox)
- It makes no difference if I use Node Express or the base http server package
- Issue doesn't happen inside WSL when accessing the app with localhost using curl or wget
This seems to be a TCP socket issue with the way WSL 2 handles the new localhost bridging out to Windows
It is trivial to reproduce. Install Node.js and run the following simple server
What's wrong / what should be happening instead:
HTTP request /page should instantly load
Strace of the failing command, if applicable:
NA
For WSL launch issues, please [collect detailed logs]
NA
See our contributing instructions for assistance.
The text was updated successfully, but these errors were encountered: