code-server: [Bug]: Unable to connect code-server
Is there an existing issue for this?
- I have searched the existing issues
OS/Web Information
- Web Browser: Edge
- Local OS: Windows 11
- Remote OS: Ubuntu 18.04
- Remote Architecture: amd64
code-server --version: 4.1.0 9e620e90f53fb91338a2ba1aaa2e556d42ae52d5 with Code 1.63.0
Steps to Reproduce
- Install code-server
- Open code-server and open port 80 port with ufw add 80
- Configure config file
- Try to connect
Expected
I should connect and start to use
Actual
I’ve always gotten “ERR_CONNECTION_REFUSED”.
Logs
root@ubuntu:~# code-server --verbose [2022-03-10T18:09:57.699Z] trace child:1605 got message {“message”:{“type”:“handshake”,“args”:{“bind-addr”:“127.0.0.1:80”,“auth”:“password”,“password”:“IDELETEDPASSWORD”,“config”:“/root/.config/code-server/config.yaml”,“verbose”:true,“user-data-dir”:“/root/.local/share/code-server”,“extensions-dir”:“/root/.local/share/code-server/extensions”,“log”:“trace”,“host”:“127.0.0.1”,“port”:80,“proxy-domain”:[],“_”:[],“usingEnvPassword”:false,“usingEnvHashedPassword”:false}}} [2022-03-10T18:09:57.706Z] info code-server 4.1.0 9e620e90f53fb91338a2ba1aaa2e556d42ae52d5 [2022-03-10T18:09:57.706Z] info Using user-data-dir ~/.local/share/code-server [2022-03-10T18:09:57.707Z] trace Using extensions-dir ~/.local/share/code-server/extensions [2022-03-10T18:09:57.755Z] info Using config file ~/.config/code-server/config.yaml [2022-03-10T18:09:57.756Z] info HTTP server listening on http://127.0.0.1/ [2022-03-10T18:09:57.756Z] info - Authentication is enabled [2022-03-10T18:09:57.756Z] info - Using password from ~/.config/code-server/config.yaml [2022-03-10T18:09:57.756Z] info - Not serving HTTPS
Screenshot/Video
No response
Does this issue happen in VS Code?
- I cannot reproduce this in VS Code.
Are you accessing code-server over HTTPS?
- I am using HTTPS.
Notes
I had this problem with my old service provider too. I’m not using HTTPS btw.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 15 (9 by maintainers)
Oh wait we do have instructions for directly exposing under the self-signed section, it just uses the config instead of command line options. We do not have a section for directly exposing without TLS but I am not sure we want to recommend that.
Anyway, very happy to take on recommendations on how to rework the documentation to make it more clear.
Here is it : https://www.youtube.com/watch?v=F9OhgO6CiLI
Also, I think we used to have the default as 0.0.0.0 but we switched to localhost for security reasons. But maybe we should add some output when listening on localhost that says “code-server will only be accessible internally” or something? Or maybe link to https://github.com/coder/code-server/blob/main/docs/guide.md#expose-code-server although currently the only options we give in that document are SSH and reverse proxies, we should maybe add instructions for directly exposing.
Node’s default when you do
app.listen(port)is to listen on 0.0.0.0 by the way, which is why it works in your video.https://nodejs.org/api/net.html#serverlistenport-host-backlog-callback
Thank you for the video!
If you are accessing a remote port directly you will need to listen on 0.0.0.0 since 127.0.0.1/localhost is accessible only from inside the machine.
Alternatively you could set up a reverse proxy that proxies to port 8080.
It also works with VSCode tunnel. I need to talk with my ISP I think. I’ll reply if the source of the problem is ISP.
It works with ngrok. I’m gonna try with VSCode tunnel.
Hmm…seems like the port isn’t being forwarded? What happens if you forward it with localtunnel or ngrok?
I’m gonna make a video about how did I install code-server.