PROBLEM SOLVED.

See my answer below please.

PROBLEM:

I'm trying to make socketio and express work on the same port and here's the error I get.

events.js:141 throw er; // Unhandled 'error' event ^ Error: listen EACCES 0.0.0.0:80 at Object.exports._errnoException (util.js:874:11) at exports._exceptionWithHostPort (util.js:897:20) at Server._listen2 (net.js:1221:19) at listen (net.js:1270:10) at Server.listen (net.js:1366:5) at Object.<anonymous> (/Users/app.js:22:8) at Module._compile (module.js:435:26) at Object.Module._extensions..js (module.js:442:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:311:12)

I can get my server started using sudo npm start, but now I have two servers running, localhost:3000 (express) and localhost:80 (express and socket.io)

How can I disable the :3000 one without breaking anything in the bin/www?

I'm using Express 4.

Here's my view

html head title Socket.io script(src="/socket.io/socket.io.js") body script(src="javascripts/ol.js")

ol.js (client side)

var socket = io.connect('http://localhost'); socket.on('news', function (data) { console.log(data); socket.emit('my other event', {my: 'data'}); });

Here's my app.js

var express = require('express'); var path = require('path'); var favicon = require('serve-favicon'); var logger = require('morgan'); var cookieParser = require('cookie-parser'); var bodyParser = require('body-parser'); var http = require('http'); var router = express.Router(); var app = express(); var server = http.Server(app); var io = require('socket.io')(server); server.listen(80); io.on('connection', function (socket) { socket.emit('news', { hello: 'world' }); socket.on('my other event', function (data) { console.log(data); }); }); io.on('error', function () { console.log("errr"); }); // view engine setup app.set('views', path.join(__dirname, 'views')); app.set('view engine', 'jade'); app.set('view options', {layout: false}); app.use(logger('dev')); app.use(bodyParser.json()); app.use(bodyParser.urlencoded({extended: false})); app.use(cookieParser()); app.use(express.static(path.join(__dirname, 'public'))); app.get('/testit', function (req, res) { res.send("it works!"); }); // catch 404 and forward to error handler app.use(function (req, res, next) { var err = new Error('Not Found'); err.status = 404; next(err); }); // error handlers // development error handler // will print stacktrace if (app.get('env') === 'development') { app.use(function (err, req, res, next) { res.status(err.status || 500); res.render('error', { message: err.message, error: err }); }); } // production error handler // no stacktraces leaked to user app.use(function (err, req, res, next) { res.status(err.status || 500); res.render('error', { message: err.message, error: {} }); }); module.exports = app;

When I use 3000 rather than 80 for server.listen AND If I use node app.js rather than npm start to run my app, I don't see any problem and everything works, but does socketio override Express.js's settings that way?

I didn't touch bin/www file at all. It's right below.