1

I am using npm http-server to start a https server with:

http-server --ssl --cert ~/.localhost-ssl/localhost.crt --key ~/.localhost-ssl/localhost.key

It defaults to 8080 port. So I can use https://192.168.22.123:8080 to access. But I wanted to not have to specify 8080 at all, for ex: https://192.168.22.123. Can it be done?

According to http-server there is a -p or --port option. But not sure if or how to do it?

Edited: It seemed like I can redirect to any ports other than well known ports. For example, I have no problem with 8081 or 4000. But if I specified 80, it gave me an error: events.js with Unhandled 'error' and Error: listen EACCES 127.0.0.1:80. I did see other posts that people were using 80.

Any suggestions why mine is not working?

user523234
  • 14,323
  • 10
  • 62
  • 102
  • 1
    On Unix for a (server) program to use a port number below 1024 either you must be running as `root` or on some variants, I don't know for MacOS, the process must have `CAP_NET_BIND'. See https://stackoverflow.com/questions/23281895/ https://stackoverflow.com/questions/9164915/ https://serverfault.com/questions/112795/ https://stackoverflow.com/questions/26579028/ Note using the default port is different from having no port at all, and the default for _HTTP_ is 80 but for HTTPS it's 443. – dave_thompson_085 May 15 '20 at 15:23
  • @dave_thompson_085: That was it. I was able to just use https without port (defaults to 443) using sudo. Thanks. If you would put this in the answer then I will make this as an accepted answer. – user523234 May 16 '20 at 15:14

0 Answers0