code-server: --link fails possibly because of the binding address

Hello, I tried to run code-server with the --link option, and it ran without printing any errors into console, pointing me to some https://****.cdr.co/ address. However, opening that address did not work for me, with the error message “cannot connect to instance…” printed on the Browser screen. Still no error in the console.

I guess the failure to connect is because --link uses 127.0.0.1 as the binding address, whereas in the VPS I use, it must be 0.0.0.0, and that’s how I manage to run code-server without --link.

Is there a way to tell --link to use 0.0.0.0 as the binding address and then some random port, instead of 127.0.0.1 and some random port? I have already set bind-addr to 0.0.0.0 in config.toml, but it is apparently ignored by --link.

Many thanks.

OS/Web Information

  • Web Browser: Chrome 92
  • Local OS: ChromeOS
  • Remote OS: Ubuntu 20.04
  • Remote Architecture: AMD Ryzen
  • code-server --version: 3.11.1

Steps to Reproduce

  1. Run code-server with --link on a server that needs the binding address to be 0.0.0.0 to be accessible outside

Expected

Access code-server via cdr.io proxy link

Actual

Code-server is not accessible via proxy link

Update: I looked into the source code and it seems that line 450 of the file cli.ts can do the trick. No?

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 22 (10 by maintainers)

Most upvoted comments

It worked. Amazing. Many thanks.

I don’t believe there’s currently a timeline. I will make sure we announce the new version release here and in #2734.

If it helps, I also live in switzerland and the server is in germany

It’s possible that the issue you’re running into is the same as https://github.com/cdr/code-server/issues/2734 which is ultimately caused by being in a different region from the cloud proxy (or server, not sure which).

If that’s the case the only known workaround is to use a VPN (the new version of link shouldn’t have this region issue).

link (just for context link is a separate binary that ships with code-server) is not a traditional reverse proxy so it does not need to be exposed (it dials out to our cloud rather than having connections dial in).

We override the host and port on code-server because we disable authentication (since link uses GitHub oauth and we don’t want users needing to log in twice) and it would be sketchy to listen on 0.0.0.0 without authentication. Only link needs to be able to communicate with code-server and they’re on the same machine so localhost works for that.

Unfortunately we don’t get much in the way of logs since the connection just fails without any additional information.

For more context on how link works check out these issues:

I think seeing code-server on localhost yet somehow “exposed” is very confusing. Maybe we should listen on a socket instead or skip the listening output altogether and say “established link to the cloud” or something like that. Documentation might also help.

Link is currently undergoing a rewrite which I think has a good chance of resolving this issue.