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

Can't connect to websocket sever deployed in wsl2 #7849

Closed
1 of 2 tasks
ghost opened this issue Dec 18, 2021 · 8 comments
Closed
1 of 2 tasks

Can't connect to websocket sever deployed in wsl2 #7849

ghost opened this issue Dec 18, 2021 · 8 comments

Comments

@ghost
Copy link

ghost commented Dec 18, 2021

Version

Microsoft Windows [Version 10.0.22000.376]

WSL Version

  • WSL 2
  • WSL 1

Kernel Version

5.10.16.3

Distro Version

Ubuntu 20.04

Other Software

Whenever I try to connect from windows to a websocket server which deployed inside wsl2 I get

"Error: getaddrinfo ENOTFOUND http".

(btw, for self-check, If I deploy it in the window itself, connection works)

Repro Steps

  1. Deploy websocket server in wsl2.
  2. Try to connect from windows.
  3. you will get an error: "Error: getaddrinfo ENOTFOUND http".

You can debug it with postman websocket feature.

Expected Behavior

connection is successful.

Actual Behavior

"Error: getaddrinfo ENOTFOUND http".

Diagnostic Logs

No response

@ghost ghost changed the title Can't connect to websocket deployed in wsl2 Can't connect to websocket sever deployed in wsl2 Dec 18, 2021
@OneBlue
Copy link
Collaborator

OneBlue commented Dec 22, 2021

Thanks for reporting this @purple-cmd.

Can you share more details about how exactly your websocket server is set up ?
What listening address and port do you use inside WSL and which ip address & port are you connecting to from Windows ?

@DanPinGF
Copy link

Sounds like a network problem. Do you have any firewalls set up?

@ghost ghost closed this as completed Dec 30, 2021
@ghost
Copy link

ghost commented Dec 30, 2021

This issue has been automatically closed since it has not had any author activity for the past 7 days. If you're still experiencing this issue please re-open it.

Thank you!

@eluo28
Copy link

eluo28 commented Jan 14, 2022

Am getting similar error when trying to connect to socket using postman. Works if I use browser as client though.
image

@wanderer-s
Copy link

image

I have a same issue with same code but different dev enviroment

when I try same process in Mac OS it works properly but when I try this in WSL2 it shows that error

@filipe-costa
Copy link

filipe-costa commented Jan 27, 2023

I am currently facing the same problem, although I have referenced this in another thread since I think it might be a network issue between Windows and WSL2 when using applications like Postman since everything seems to work via a browser:

#4204 (comment)

Is it necessary to add any firewall rules since I can make another HTTP request per my post via Postman and other Postman-like applications?

@m-salman-afzal
Copy link

For anyone,
My issue was server was started on ipv6 which was unable to listen. You can use sudo lsof -i -P -n | grep LISTEN to check if your port is ipv6 or ipv4. If ipv6, then try putting 0.0.0.0 after port. The issue for connection refused will be solved.

BUT, you might get a new error socket hang up. Now, this will be because you are using socket.io library and going through the documentation, it seems like it expects socket.io-client, its own library for proper handshake to establish a connection. So, we might not be able to do it from postman at all.

What you can try is using the base ws library which is barebone of websockets (upon which socket.io runs). I was able to establish a connection through it. But being barebone, you will have to do everything yourself if you go down this road.

@lumusitech
Copy link

Same problem. Goodbye WSL2 development environment in windows 11. I Return to others OS like macos or GNU linux to solve this problem.

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

No branches or pull requests

7 participants