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

localhost:3000 / 127.0.0.1:3000 nodejs server unable to connect via windows browsers #8509

Closed
1 of 2 tasks
Tracked by #11025
Sandy-Garrido opened this issue Jun 13, 2022 · 7 comments
Closed
1 of 2 tasks
Tracked by #11025

Comments

@Sandy-Garrido
Copy link

Sandy-Garrido commented Jun 13, 2022

Version

Microsoft Windows [Version 10.0.22000.708]

WSL Version

  • WSL 2
  • WSL 1

Kernel Version

5.10.102.1

Distro Version

Ubunutu 20.04.4 LTS

Other Software

No response

Repro Steps

  • Start a nodejs server with port 3000 via WLS
  • Try to access via windows browser localhost:3000 or 127.0.0.1:300
  • Unable to access it.

Expected Behavior

  • be able to connect via localhost:3000 or 127.0.0.1:3000

Actual Behavior

Unable to connect to localhost wsl nodejs server

I am however able to access it via the wsl ip 172.29.229.115:3000 but this IP changes every time I restart or restart WSL which isn't useful for me every time as the project I'm working on requires the host to be a particular domain which I set via HOSTS.

I don't recall this working in the past as it's the first time I've needed to have a specific domain set in my host file

Diagnostic Logs

No response

@elsaco
Copy link

elsaco commented Jun 14, 2022

@Sandy-Garrido the loopback interface in Windows is separate from the loopback interface in a WSL instance. However, you can use portproxy to make the connection. A similar issue was discussed here not too long ago. Please check #8431

@Sandy-Garrido
Copy link
Author

@Sandy-Garrido the loopback interface in Windows is separate from the loopback interface in a WSL instance. However, you can use portproxy to make the connection. A similar issue was discussed here not too long ago. Please check #8431

Hmm, thanks, though That answer suggests to enter the wsl ip all the time, this changes, so does that mean I will have to change this every time ?
Did I mention already that I can already connect if I just wsl.ip.x.x:3000 but I need a solution that doesn't require me to edit something every time I log into my pc

@elsaco
Copy link

elsaco commented Jun 14, 2022

@Sandy-Garrido is this what you're trying to connect?

   Window               WSL/node
127.0.0.1:3000 <---> 127.0.0.1:3000

@Sandy-Garrido
Copy link
Author

@Sandy-Garrido is this what you're trying to connect?

   Window               WSL/node
127.0.0.1:3000 <---> 127.0.0.1:3000

Doh 🤦‍♂️ I see where you're going with that I think. I'll give that solution a try haha

@Sandy-Garrido
Copy link
Author

Sandy-Garrido commented Jun 14, 2022

@Sandy-Garrido is this what you're trying to connect?

   Window               WSL/node
127.0.0.1:3000 <---> 127.0.0.1:3000

Hey, so I tried:
-windows netsh interface portproxy add v4tov4 listenport=3000 connectport=3000 connectaddress=127.0.0.1 protocol=tcp
-wsl export http_proxy=http://127.0.0.1:3000

However, it's still not giving me the desired result, just doesn't want to connect. Am I missing something from that thread?

btw, yes, was the answer to your question I quoted

@ghost ghost self-assigned this Jun 14, 2022
@Sandy-Garrido
Copy link
Author

Okay, whilst yes, what I wanted didn't work. With your comments etc, I've managed to at least create a logon script that will get the WSL IP and run the netsh command so that I don't need to keep changing it! thanks for you're help!

@Majikmikewrightedu
Copy link

Calc84

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

3 participants