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.
Change the port property in server/config.json. See https://github.com/strongloop/loopback-sandbox/blob/master/server/config.json#L4
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With