How to resolve a Socket.io 404 (Not Found) error?

If you’re running Express 4, it appears to me like you’re missing the lines of code:

var app = express();
var server = app.listen(3000);

That will start your web server and set it to port 3000. See the bone simple Express 4 app here: http://expressjs.com/4x/api.html

And, then to start up socket.io, you would add:

var io = require('socket.io').listen(server);

And, there is no need for this line:

var http = require('http');

Leave a Comment