I'm getting so frustrated... I can't find any information online to help me.
My setup is:
I've tried using my public DNS/public IP and restarting nginx, I've tried port 80, 8000, 1337, etc... I've tried deleting Nginx. ps aux | grep :3000 returns nothing. ps aux | grep :80 returns nothing. etc...
Here's the relevant code:
https.createServer(options, app).listen(app.get('port'), '127.0.0.1', function() {
console.log('Express server listening on port ' + app.get('port'));
});
http.createServer(function(req, res) {
res.writeHead(301, { "Location": "https://" + req.headers['host'] + req.url });
res.end();
}).listen(3000);
No matter which port I use, I get the same error for sudo node app.js and node app.js:
events.js:72
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE
at errnoException (net.js:904:11)
at Server._listen2 (net.js:1042:14)
at listen (net.js:1064:10)
at net.js:1146:9
at dns.js:72:18
at process._tickCallback (node.js:419:13)
at Function.Module.runMain (module.js:499:11)
at startup (node.js:119:16)
at node.js:906:3
I did get this to work, but I need to redirect traffic to port 443 and use https:
app.listen(3000, '127.0.0.1', function() {
console.log('Express server listening on port ' + app.get('port'));
});
You can use netstat -tulpn | grep :XX , XX being the port you want to check.
It seems that you're trying to start both a http and a https server on the same port. delete the http.createServer bit and you'll be fine.
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