When I start my webserver, node throws listen EADDRINUSE: address already in use :::3000
, I tried to use netstat and search for 3000 port (or another, it happens with any port), but nothing found. Also no node processes in task manager, no webpage on localhost:3000
. Also I tried to reload windows, but nothing changed.
From your code you are trying to bind the socket module to port 3000:
var io = require('socket.io')(3000);
/* ... */
app.listen(3000);
in this way when the server tries to bind itself the port is already in use
.
You have to create the HTTP server and then bind the socket.io module on it:
const app = require('express')();
const server = require('http').createServer(app);
const io = require('socket.io')(server);
io.on('connection', () => { /* … */ });
server.listen(3000);
(taken from the socket.io documentation)