I've got a socket application that I'm trying to make listen on port 443 (https). If I change the port (to e.g. 8080) I get no problems.
The error shown is
error raised: Error: listen EACCES
My app source code is:
var fs = require('fs');
// create the https server and listen on port
var options = {
ca: fs.readFileSync('ca.pem'),
cert: fs.readFileSync('cert.pem'),
key: fs.readFileSync('server.key')
};
var server = require('https').createServer(options);
var portNo = 443;
var app = server.listen(portNo, function() {
console.log((new Date()) + " Server is listening on port " + portNo);
});
// create the socket server on the port
var io = require('socket.io').listen(app);
// This callback function is called every time a socket
// tries to connect to the server
io.sockets.on('connection', function (socket) {
console.log((new Date()) + ' Connection established.');
// When a user send a SDP message
// broadcast to all users in the room
socket.on('message', function (message) {
socket.broadcast.emit('message', message);
});
// When the user hangs up
// broadcast bye signal to all users in the room
socket.on('disconnect', function () {
// close user connection
console.log((new Date()) + " Peer disconnected.");
socket.broadcast.emit('user disconnected');
});
});
I've seen plenty of answers relating to Linux telling them to run as sudo so I tried running the node server as administrator but to no avail.
This is running on a Windows Server 2012 box.
Thanks.
I would just like to add that if you do not have root permission level when you start your node app you will not be able to run on port 443
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