Skip to content

Digital ocean guide: ERR_CONNECTION_REFUSED #737

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

Closed
jorgt opened this issue Jun 2, 2019 · 11 comments
Closed

Digital ocean guide: ERR_CONNECTION_REFUSED #737

jorgt opened this issue Jun 2, 2019 · 11 comments

Comments

@jorgt
Copy link

jorgt commented Jun 2, 2019

After following the DigitalOcean guide, I cannot seem to be connect to the code instance: ERR_CONNECTION_REFUSED in ubuntu droplet on DigitalOcean when entering the public IP address of the droplet.

Running as root. Instance is started with a self signed certificate as per the other guide:

INFO  code-server v1.1119-vsc1.33.1
INFO  Additional documentation: http://github.com/cdr/code-server
INFO  Initializing {"data-dir":"/root/.local/share/code-server","extensions-dir":"/root/.local/share/code-server/extensions","working-dir":"/root/code-server1.1119-vsc1.33.1-linux-x64","log-dir":"/root/.cache/code-server/logs/20190602040823676"}
INFO  Starting webserver... {"host":"0.0.0.0","port":"80"}
INFO
INFO  Password: nnnnnnnnn
INFO
INFO  Started (click the link below to open):
INFO  https://localhost:80/
INFO
INFO  Starting shared process [1/5]...
WARN  stderr {"data":"(node:1491) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.\n"}
INFO  Connected to shared process

wget says:

# wget --verbose localhost:80
--2019-06-02 04:34:26--  http://localhost/
Resolving localhost (localhost)... 127.0.0.1
Connecting to localhost (localhost)|127.0.0.1|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://localhost/ [following]
--2019-06-02 04:34:26--  https://localhost/
Connecting to localhost (localhost)|127.0.0.1|:443... failed: Connection refused.
Resolving localhost (localhost)... 127.0.0.1
Connecting to localhost (localhost)|127.0.0.1|:443... failed: Connection refused.

firewall seems inactive:

# sudo ufw status
Status: inactive

starting code-server on port 443 works in the sense that it connects, but then the websocket bombs out with status code 400.

Related Issues

@jorgt jorgt added the question label Jun 2, 2019
@deansheather
Copy link
Member

Are you by any chance using a reverse proxy or maybe another http server (nginx, apache) on the machine?

@jorgt
Copy link
Author

jorgt commented Jun 2, 2019 via email

@deansheather
Copy link
Member

I tried the DO guide myself and I found the issue. Essentially, the HTTP to HTTPS redirect is causing an issue when the server is running on port 80.

I made a PR to alter the behavior on port 80, and another one to change the documentation to use a port that isn't affected by the issue (also without requiring sudo). Both are linked above this comment.

@jorgt
Copy link
Author

jorgt commented Jun 11, 2019

I tried the standard port and it works

@cyriltw
Copy link

cyriltw commented Apr 26, 2020

I'm having the same problem as @jorgt, but after upgrading. I was running v2.1698-vsc1.41.1 and I just updated the server to the latest version v3.1.1. My problem is, I get the connection refused, but when I try to do a wget --verbose localhost:8080, it seem to working pretty fine.

One thing that bugged me was when I ran the code sever, on the updated it says;
info HTTP server listening on http://127.0.0.1:8080

but on v2
info HTTP server listening on http://localhost:8080

Nevermind, found it out. It was due to the way -v3 moving to 127.0.0.1. If anyone finds this, try adding the --host flag.
./code-server --host 0.0.0.0

@jeromemeichelbeck
Copy link

jeromemeichelbeck commented Apr 26, 2020

Nevermind, found it out. It was due to the way -v3 moving to 127.0.0.1. If anyone finds this, try adding the --host flag.
./code-server --host 0.0.0.0

Thank you, I just tried to install it today and couldn't make it work.
It seems like v3 is not so easy to use as v2...

@cyriltw
Copy link

cyriltw commented Apr 26, 2020

Nevermind, found it out. It was due to the way -v3 moving to 127.0.0.1. If anyone finds this, try adding the --host flag.
./code-server --host 0.0.0.0

Thank you, I just tried to install it today and couldn't make it work.
It seems like v3 is not so easy to use as v2...

Thats weird, v3 has added some restrictions though. I have it working without any issues (so far). I wrote a guide on it (link).

@code-asher
Copy link
Member

Huh, that's curious. localhost must be resolving to something other than 127.0.0.1 on these systems, something that's externally accessible?

@jeromemeichelbeck
Copy link

It works with an nginx reverse proxy, but without a proxy I can't access it on port 8080 if I don't put the --host 0.0.0.0 option

@code-asher
Copy link
Member

That's the expected behavior, actually. localhost/127.0.0.1 is supposed to be only accessible internally in the machine so you have to use a proxy or an externally accessible host like 0.0.0.0.

I'm not sure why the output says 127.0.0.1 now. We still use localhost when creating the http server. Maybe it's a difference between Node v12 and v10.

@truehang
Copy link

I'm having the same problem as @jorgt, but after upgrading. I was running v2.1698-vsc1.41.1 and I just updated the server to the latest version v3.1.1. My problem is, I get the connection refused, but when I try to do a wget --verbose localhost:8080, it seem to working pretty fine.

One thing that bugged me was when I ran the code sever, on the updated it says; info HTTP server listening on http://127.0.0.1:8080

but on v2 info HTTP server listening on http://localhost:8080

Nevermind, found it out. It was due to the way -v3 moving to 127.0.0.1. If anyone finds this, try adding the --host flag. ./code-server --host 0.0.0.0

Thanks, more convenient way is to modify ~/.config/code-server/config.yaml, replace 127.0.0.1 with 0.0.0.0 in bind-addr field; then just systemctl restart code-server@${USER} (assume you use service to code-server) and everything is fine.

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

6 participants