How can I run loopback application on port 80 How can I run loopback application on port 80 express express

How can I run loopback application on port 80


This is similar to problems seen in Express; one such answer is here Node.js + Express: app won't start listening on port 80

I don't see it explicitly noted in the documentation, but have also had the issue where listening on port 80 required sudo (root). The loopback.js documentation https://apidocs.strongloop.com/loopback/#app-listen states that your call is just passed to the HTTP Server class https://nodejs.org/api/http.html#http_server_listen_port_hostname_backlog_callback but your format also matches that of Express (hence the first link).

Your error message would be helpful in knowing if root access is the problem or if it's something else.


I needed to set the port dynamically so that it would be 3001 in development and 80 in production. This is what worked for me:

app.start = function() {    //change the port if needed for production    if (process.env.PORT) {      app.set('port', process.env.PORT);  }  // start the web server  return app.listen(function() {...