-
Notifications
You must be signed in to change notification settings - Fork 835
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
Cannot connect to 127.0.0.1, localhost, or linux IP address #4353
Comments
You've not copied and pasted a full set of commands to reproduce. Can you give a minimal example? One odd thing with the new localhost win10->wsl2 implementation is that the linux process needs to bind to 0.0.0.0 in order for win10 to access on localhost. I suspect this will be fixed before long. example: |
Big fan of accessing development stuff via localhost without having to configure security and access. localhost on WSL2 is great news. Now, if you have to set 0.0.0.0 on every piece of software you don't really benefit of the localhost simple access feature. Tried mysql and postgresql, they need to bind to 0.0.0.0 to accept connections from outside. RabbitMQ admin plugin web interface works fine via localhost (guest account by default works only via localhost). I hope the localhost access would expand to most services without additional setup (like bind 0.0.0.0), if possible. localhost accesss made WSL so much easier to use compared to the traditional development vm. |
Good point. I've added a specific example of ssh port forwarding that normally works - it is connecting to a remote mongodb instance but anything that you have in your network should behave similarly. |
If I'm reading it right you right you have the following setup
interesting pattern! Have you tried: and setting GatewayPorts yes in /etc/ssh/sshd_config My inspiration came from this: As I mentioned in an earlier post you need for ports to bind to 0.0.0.0 with wsl2 at the moment - I'm hoping the suggestion above will cause the ssh port binding to bind to 0.0.0.0 and the GatewayPorts would expose the port to Win10 (and potentially to other PCs on your network!) |
Thanks for posting. I have identified an issue with the localhost feature and we are working on a fix. Binding to either localhost or 0.0.0.0 should work, but it seems only the later is working currently. |
Yeah - I have a number of mongo servers running elsewhere that don't have the ports exposed I normally connect to from wsl using the mongo cli but I have some Windows GUI tools that make some things easier so necessitating the song-and-dance
This works.! Brilliant, thank you.
This does not appear to be needed - I'm guessing because I'm using ssh and not sshd to provide the forwarding. Thanks for the help and hopefully Ben will have a fix Soon (tm) |
is there any work around for docker? |
try this, only for docker:docker-desktop-wsl2-tech-preview |
Still not work in 18963😭😭😭 |
Fixed in 18970. |
I'm on 18999, and I cannot use localhost. Trying to get to a mysql server. 172.29.181.182 works, but not 127.0.0.1 or localhost. do I have to do something special for localhost to work? |
I rebooted. VM IP is now 192.168.229.123/20 |
Still broke in 18995. Was more reliable than before, but gave up on mysql after a few hours |
I'm on 18995.1, it works using "localhost" |
Yes, it works "most of the time", if you boot up you can access anything run on WSL2 via localhost:port, but alas after a few hours it gets flakey again, not 100% for example already established long running connection such as persistent DB connection remain but struggles establishing new connections. It's much more reliable than earlier "localhost" featured versions |
It would be very useful if somebody could identify an app or workflow that can reliably trigger any remaining issues. |
Just another observation, after last night hibernation I can't access /mnt/c/ inside WSL2 or localhost:port from windows, the WSL2 kernel has been up evident by uptime. wsl --shutdown and opening terminal again worked. Perhaps suspension/hibernation has an impact? |
I just switched to the insider previews, and switched my WSL distro to v2, and while it worked once, rebooting my system for something else caused this problem to begin.
I am able to ping out of ubuntu, but starting a simple Edit: Forgot Windows build version:
Also was running |
I can now confirm that even with a fresh reinstall of WSL2 with Ubuntu 18.04, it still has the same issue. |
At least now I can wsl --shutdown and reopen a terminal and get back localhost connectivity (and /mnt/c access) But it (localhost and mnt/c - I guess the whole interop services) never works on resume from standby/sleep (i.e. close laptop in evening and open in morning) - wondering is the standby/resume issue is considered somewhere else or perhaps laptop usage isn't considered at the moment @benhillis is there an issue for sleep resume? cant seem to find it (perhaps using wrong terminology - standby/suspend/resume/hibernation/sleep? ) |
I tried the |
It does look to be something sleep related. After a fresh reboot yesterday, I was able to access items via localhost, but today, I have been unable to after placing my system into sleep mode. |
I'm using Laravel. Running Same with Spring/Tomcat. My issues began when I installed Docker Desktop Edge for Windows with wsl2 integration. Edit: |
I have a issue that looks like this but was better described on #4347 which was closed as duplicated by this. Anyways, here is the description:
Apache2 default site is working great from Windows with When I create a new Virtual Host on Apache2, with a different tld like I put I'm describing it here again because @craigloewen-msft closed #4347 in favor of this issue, but I'm not seeing any description that looks like my use case here, so I'm documenting it. |
I realized that, if I put:
instead of
in the Windows hosts file, it works, I don't know if this is a normal behaviour for IPv6 |
I can reliably reproduce this with |
I'm using build 10.0.19041.21, also have the same problem. In my memory, I have successfully connected to 127.0.0.1:8080 only once using Any progress made so far? |
I have PG::ConnectionBad - could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432? |
I have PostgreSql 8.4 installed on an WSL distro (Ubuntu 18.04). If I kill a locked JDBC (running an alter table query on a read locked table using DataGrip) connection to the database server, all listening sockets on wslhost.exe disappears. Maybe wslhost.exe crashes? |
For what it's worth, I also use postgresql on 9.5 and on a Rails setup. I can't imagine such a critical issue going unfixed for so much time, are people just not using WSL2 for developing anything on the web? I was hoping to but I guess with this issue the hype just comes crashing to the ground when a basic function can't work correctly. |
I believe WSL2 in current shape is useless for anything that involves networking. And in today's world, that's pretty much everything. If you want to develop web apps, having Apache on WSL2 is useless, as there are bunch of hoops to jump through, and even those aren't guaranteed to work. You can't reliably access that web server from outside, nor occasionally from local PC. If you want to use that WSL2 for management & monitoring tools to manage other (real) Linux servers using remote management/monitoring, again you have to rely on buggy and badly thought through network implementation. I'm not even talking about bunch of other scenarios people do or try to do with WSL2. I'm talking about 99% of what WSL was made to solve - give developers and admins (be it net/sys/db) access to tools from Linux ecosystem. From my point of view, it fails for most admin and dev uses with current networking stack. We're all way better off creating our own lightweight VMs on Hyper-V, that's just 4GB disk space and 10min of time. Slightly longer than installing WSL distro through Store, but you have 100% compatibility, 100% access to networking, and it is a reliable solution. We aren't meant to be browsing web from WSL2, and that's just about it in a list of networking features that work on WSL2. I beg excuse of all developers that are spending countless hours on this project, indeed a wonderful project with huge potential. But I hope you people still get the point. Perhaps you should just ask project managers to rethink the strategy... |
for me the only that works accessing WSL2 server apps from windows 10 :
made a small server in go and tested http://172.20.203.35:3006/ |
This was working for me prior to 18945
Please fill out the below information:
Your Windows build number: (Type
ver
at a Windows Command Prompt)10.0.18945.1001]
What you're doing and what's happening: (Copy&paste the full set of specific command-line steps necessary to reproduce the behavior, and their output. Include screen shots if that helps demonstrate the problem.)
Trying to access network ports in my WSL2 (port forwarded via ssh over vpn) via localhost or 127.0.0.1 or eth0 IP address and getting connection refusal
ssh -i ~/.ssh/your.key -l username -L 27027:mongo.server.ip:27017 -N -f mongo.server.ip
I should be able to connect from the windows host (eg in browser, or sql editor) to linux ports eg 127.0.0.1:8080 or localhost:27017
"message" : "failed to connect to server [localhost:27027] on first connect [MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27027]
Connecting from Linux out (eg to initialize ssh port forwarding or lynx localhost:8080) works.
I can ping the linux IP but not connect to that either
Network Info from wsl:
ip a
ip r
From windows
ifconfig
ping
route print -4
The text was updated successfully, but these errors were encountered: