0

I'm an Azure App Service noob - I thought it would be pretty much turnkey, but I'm having some port issues it looks like. I've deployed a Node/Express web app to App Service...

When I designate the port to 80 in my Node/Express app and deploy, I can't reach the website. When I go into console and node app.js, I get the error "Error: listen eacces: permission denied 0.0.0.0:80"

When I've used 3000, I get an error that states something else is listening on 3000.

Am I designating incorrect ports? Documentation seems to say that 80 is one of two ports to use with Azure App Service. How do I fix this error or what is the correct port to use?

Thank you

Edit: This running on Windows inside of Azure App Service

Mark Hardy
  • 19
  • 5

1 Answers1

1

When I go into console and node app.js, I get the error "Error: listen eacces: permission denied 0.0.0.0:80"

The error indicates that the app is trying to listen on port 80, which requires elevated privileges.

  • In Azure App Service, the port provided by the PORT environment variable should be used.
  • This environment variable can be found in the script bin/www in your generated Express app as shown below:
var  port = normalizePort(process.env.PORT || '3000');
app.set('port', port);

To fix the issue, you can change the port in your Node/Express app to use the PORT environment variable. You can also check if there is another process running on port 3000 by running the below command as mentioned in SO:

netstat -ano | findstr :3000------> To check if any process running
tskill <Process_ID>------>to kill the process

If there is another process running on port 3000, you can either stop that process or use a different port in your Node/Express app.


I have created a sample nodejs/expressjs application to check in my environment. Server code:

var  express = require('express');
var  app = express();  
app.get('/', function (req, res) {
res.send('Hello World!');
});

var  port = process.env.PORT || 3000;  
app.listen(port, function () {
console.log('Example app listening on port ' + port + '!');
});

Result:

Running the app in port 80: enter image description here enter image description here

Running the app in port 3000: enter image description here enter image description here

Portal: enter image description here

Pravallika KV
  • 2,415
  • 2
  • 2
  • 7