Skip to content

DO Guide - ERR_CONNECTION_REFUSED - CentOS 7 #1875

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
sn1f3rt opened this issue Jul 10, 2020 · 11 comments
Closed

DO Guide - ERR_CONNECTION_REFUSED - CentOS 7 #1875

sn1f3rt opened this issue Jul 10, 2020 · 11 comments
Labels
waiting-for-info Waiting for more information from submitter

Comments

@sn1f3rt
Copy link

sn1f3rt commented Jul 10, 2020

Hello,

So I installed code-server following this guide - https://www.digitalocean.com/community/tutorials/how-to-set-up-the-code-server-cloud-ide-platform-on-centos-7 Before proceeding onto the subdomain configuration, I wanted to ensure that it's working and to my dismay I'm only getting an ERR_CONNECTION_REFUSED in the web browser.

  • Web Browser: Google Chrome
  • Local OS: Windows 7 Professional
  • Remote OS: CentOS Linux release 7.8.2003 (Core)
  • Remote Architecture: x86_64
  • code-server --version: v3.4.1

At first, I'd like to mention that I've a previously running VestaCP installation on that server, so Apache and Nginx were pre-installed and running. Now, I was trying to bind code-server to port 1313, which has been opened in the firewall.

[root@sohamb03 ~]# systemctl status code-server
● code-server.service - code-server
   Loaded: loaded (/usr/lib/systemd/system/code-server.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2020-07-10 03:03:27 EDT; 5ms ago
 Main PID: 19902 ((e-server))
   CGroup: /system.slice/code-server.service
           ‣ 19902 [(e-server)]

Jul 10 03:03:27 sohamb03.tk systemd[1]: Stopped code-server.
Jul 10 03:03:27 sohamb03.tk systemd[1]: Started code-server.

But again sudo lsof -i:1313 produces no output. :(

Here's the code-server.service file.

[Unit]
Description=code-server
After=nginx.service

[Service]
Type=simple
Environment=PASSWORD=testpass123
ExecStart=/usr/bin/code-server --bind-addr 0.0.0.0:1313 --user-data-dir /var/lib/code-server --auth password
Restart=always

[Install]
WantedBy=multi-user.target

I've checked issue #737 but doesn't seem to help either.

@code-asher
Copy link
Member

code-asher commented Jul 10, 2020

Are you accessing code-server directly through port 1313 or are you going through Apache or Nginx? nvm, looks like you're trying to access it directly but correct me if I'm wrong.

@code-asher
Copy link
Member

Ah but the lsof command producing no output is suspicious. Could you check code-server's output?

@sn1f3rt
Copy link
Author

sn1f3rt commented Jul 10, 2020

Yeah I was accessing it directly on the public IP.

Also, lsof didn't produce an output bcuz code-server was already broken at that time. As far as I guess, it's something to do with the service file cuz it works when I use code-server --bind-addr 0.0.0.0:1313 manually.

@code-asher
Copy link
Member

code-asher commented Jul 10, 2020

I remember there seemed to be an issue with user systemd units in Centos, maybe that's what's going on. Discussion/solution here: #1771

@sn1f3rt
Copy link
Author

sn1f3rt commented Jul 11, 2020

I'm still getting a ERR_CONNECTION_REFUSED

Here's how my /etc/systemd/system/code-server.service file looks like now:

[Unit]
Description=code-server
After=nginx.service

[Service]
Type=simple
Environment=PASSWORD=testpass123
ExecStart=/usr/bin/code-server --bind-addr 0.0.0.0:1234 --user-data-dir /var/lib/code-server --auth password
Restart=always
User=root

[Install]
WantedBy=multi-user.target

@code-asher
Copy link
Member

Is there any output from code-server when it runs via the systemd service? It should output the version number among a few other things.

@sn1f3rt
Copy link
Author

sn1f3rt commented Jul 14, 2020

Hmm, I don't think. It fails as soon as it starts. Here's the output:

[root@google ~]# systemctl status code-server -l
● code-server.service - code-server
   Loaded: loaded (/etc/systemd/system/code-server.service; enabled; vendor preset: disabled)
   Active: activating (auto-restart) (Result: exit-code) since Tue 2020-07-14 08:13:47 IST; 4ms ago
  Process: 1245 ExecStart=/usr/bin/code-server --bind-addr 0.0.0.0:1234 --user-data-dir /var/lib/code-server --auth password (code=exited, status=203/EXEC)
 Main PID: 1245 (code=exited, status=203/EXEC)

Jul 14 08:13:47 google.tk systemd[1]: code-server.service: main process exited, code=exited, status=203/EXEC
Jul 14 08:13:47 google.tk systemd[1]: Unit code-server.service entered failed state.
Jul 14 08:13:47 google.tk systemd[1]: code-server.service failed.

@code-asher
Copy link
Member

Interesting, maybe that 203/EXEC has something to do with it. Some sort of issue with executing the code-server script maybe?

What if you tried launching the script directly instead of using the symlink? It should be /var/lib/code-server/bin/code-server (instead of /usr/bin/code-server).

If that doesn't work, maybe running it with Node directly will work: /var/lib/code-server/lib/node /var/lib/code-server.

@sn1f3rt
Copy link
Author

sn1f3rt commented Jul 16, 2020

Umm, I never thought about that. I'll give it a try and update you soon. :)

@Spacebody
Copy link

Spacebody commented Oct 3, 2020

Umm, I never thought about that. I'll give it a try and update you soon. :)

Just change the line in service:

ExecStart=/usr/bin/code-server --bind-addr 0.0.0.0:1234 --user-data-dir /var/lib/code-server --auth password

to

ExecStart=/usr/bin/code-server/code-server --bind-addr 0.0.0.0:1234 --user-data-dir /var/lib/code-server --auth password

then it will work correctly.

That is because the binary file is in the directory /usr/bin/code-server/, the binary file itself is also called code-sever.

@code-asher code-asher added the waiting-for-info Waiting for more information from submitter label Dec 2, 2020
@nhooyr
Copy link
Contributor

nhooyr commented Jan 18, 2021

Going to close as there hasn't been a response in a long time!

@nhooyr nhooyr closed this as completed Jan 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting-for-info Waiting for more information from submitter
Projects
None yet
Development

No branches or pull requests

4 participants