Skip to content

code-server should print error when it can't listen on ports < 1024 #861

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
khaosdoctor opened this issue Jul 21, 2019 · 4 comments
Closed
Labels
bug Something isn't working

Comments

@khaosdoctor
Copy link

  • code-server version: 1.1156-vsc1.33.1
  • OS Version: Ubuntu 18.4 LTS on Azure

Description

As #737 states, code-server is giving a connection refused error when listening on ports 80 or 443. All other ports work as expected. This is due to the fact that the server does not bind itself to the ports 80 or 443, so the provider has no available listener to answer the socket.

Steps to Reproduce

  1. Run code-server as of ./code-server -p 80 -H &
  2. Run sudo netstat -tnlp and see there's no code-server process running

image

  1. Do the same thing for port 443
  2. Try with a different port passing -p 2345
  3. Run sudo netstat -tnlp again
  4. Code-server appears as a listener

image

@khaosdoctor khaosdoctor added the bug Something isn't working label Jul 21, 2019
@deansheather
Copy link
Member

If you're using any ports less than 1024 you'll need to run as root or with sudo. Leaving this open as code-server should be erroring out when it can't listen on the specified port.

@deansheather deansheather changed the title Code server does not listen on ports 80 or 443 code-server should print error when it can't listen on ports < 1024 Jul 22, 2019
@khaosdoctor
Copy link
Author

Oh! Thanks for the quick response! Will try with sudo

@antofthy
Copy link

It is possible for code-server or other user services to bind to ports lower than 1024, but only if you tell the kernel to ignore that 'root-only' restriction. Something about using setcap CAP_NET_BIND_SERVICE to give permission.

I would however... NEVER however run code-server as root. Unless that server was specifically designed to do so, like apache, that creates non-root worker processes, it is simply not a good idea.

User access to root even in a docker container is really a BAD IDEA! And code server can provide not only file access, but terminal access! As such Sudo is a not a good solution.

@code-asher
Copy link
Member

v2 will now error and report something like:

error listen EACCES: permission denied 0.0.0.0:80

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants