Reputation: 1226
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.
Upvotes: 2
Views: 8543
Reputation: 927
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
Upvotes: 8
Reputation: 35117
Have you verified that port 443 isn't already being used?
Go to your command line and run netstat -a
and verify that :443 is not already in the list. If it is you'll need to terminate whatever process is using that port before proceeding.
Upvotes: 2