Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I run loopback application on port 80

I'm using loopback.io which base on expressjs and I tried to add port as the first parameter of app.listen like this:

// server.js

app.start = function() {
  // start the web server
  return app.listen(80, function() {
    app.emit('started');
    console.log('Web server listening at: %s', app.get('url'));
  });
};

But it doesn't work.

I have been searching for this for awhile but I haven't found the solution yet.

like image 474
iboss Avatar asked Dec 19 '25 04:12

iboss


2 Answers

Change the port property in server/config.json. See https://github.com/strongloop/loopback-sandbox/blob/master/server/config.json#L4

like image 190
superkhau Avatar answered Dec 20 '25 16:12

superkhau


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.

like image 21
Greg Syme Avatar answered Dec 20 '25 18:12

Greg Syme