I\'ve been following this(http://socket.io/get-started/chat/) tutorial on how to make a simple chat application using socket.io.
I tried to however use Express to create
I ran into this problem too and I solved it by this:
Do not use npm start
to start your web app
Use node app.js
instead
I resolved the same problem with an express app doing this:
find the line :
var port = normalizePort(process.env.PORT || '3000');
replace it by:
var port = normalizePort('XXXX');
where XXXX is the port number you want to use
Then youre free to do npm start! xD
I solved it by this:
npm install shelljs
and add code for kill nodejs process before start listen port
var shell = require('shelljs');
shell.exec("pkill nodejs");
shell.exec("pkill node");
/* Make the http server listen on port 3000. */
http.listen(3000, function(){
console.log('listening on *:3000');
});
One of the best way to do this during the development would be through IDE where you can do comprehensive debugging and step through the code.
If you are using WebStorm, this works.
From run configurations -> Edit Configurations -> Nods.js and add the app.js
as the node parameter. See below arrow in the screenshots for more details.
for me helps to make use 3000 || 3333
, and it's fix the issue
I had (forgotten that I had) previously installed ntop, which by default also uses port 3000, and was therefore getting the same error as described here.
As others have mentioned, use netstat or lsof to find the offending service (and prefix the command with sudo, to get the correct process name):
sudo lsof -P | grep ':3000'
- or -
sudo netstat -anp tcp | grep 3000
On Ubuntu, the service is disabled with (simply):
service ntop stop