Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: listen EACCES 0.0.0.0:8080 but can't find PORT?

I have this code currently:

var express    = require('express');        
var app        = express();                 
var bodyParser = require('body-parser');

var sessionManager = require("./SessionRaterBL");
sessionManager.CreateTestData();


app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());

var port = process.env.PORT || 8080;       


var router = express.Router();              
var sessionRouter = express.Router();


router.get('/', function(req, res) {  
res.json({ message: 'API Session Rater Backend' });  
});

sessionRouter.get("/",function(req,res){
res.json(sessionManager.GetSessions())     
});

sessionRouter.get("/:id",function(req,res){
    var session;
    try{
        session = sessionManager.GetSession(req.param.id);
        res.json(session);
    }catch(ex){
        res.status(404).send(ex);
    } 
});


app.use('/api', router);
app.use('/api/sessions',sessionRouter);

app.listen(port);
console.log('Magic happens on port ' + port);

When executing the program I get the above named error.

So I did a netstat -anb I get this: all ports

So I tried finding the PORT 8080 or 80 but I just could not find it. If I execute my Node.js Program with a different Port for example: 1000. It works!.

like image 546
DYRtLAWWWOTS Avatar asked Dec 23 '22 12:12

DYRtLAWWWOTS


1 Answers

I had the same problem.

What I did was I changed the port of the default website in the IIS-Manager from 8080 to 80 and than I reseted the IIS-Manager. It worked!

like image 141
KeyNavas Avatar answered Jan 13 '23 12:01

KeyNavas