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

Created on 21 Jul 2019  路  4Comments  路  Source: cdr/code-server

  • 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

bug

All 4 comments

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.

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

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.

v2 will now error and report something like:

error listen EACCES: permission denied 0.0.0.0:80
Was this page helpful?
0 / 5 - 0 ratings

Related issues

sa7mon picture sa7mon  路  3Comments

nol166 picture nol166  路  3Comments

broady picture broady  路  3Comments

infogulch picture infogulch  路  3Comments

avelino picture avelino  路  3Comments