Websocket Server - Error in the npm server.js command

Asked

Viewed 30 times

0

I tried to execute the command npm server.js and he turns me into that mistake:

Error: System EADDRINUSE ::3000 At object. _errnoException (util.js:992:11) at _exceptionWithHostPort (util.js:1014:20) At server.setupListenHandle [as _listen2] (net.js:1355:14) listenInCluster (net.js:1396:12) At Server.Listen (net.js:1480:7) At object. (C: xampp htdocs 123 server.js:15:6) At Module. _Compile (module.js:652:30) At object.Module. _Extensions.. js (module.js:663:10) at Module.load (module.js:565:32) at tryModuleLoad (module.js:505:12) At function.Module. _load (module.js:497:3) At Function.Module.runMain (module.js:693:10) at startup (bootstrap_node.js:191:16) at bootstrap_node.js:612:3

js server.:

var http= require('http').createServer(function (req,res) {res.end()})
var io = require('socket.io')(http)
var Redis = require('ioredis')
var redis = new Redis(6379,'127.0.0.1')

redis.psubscribe('*', function (){

  redis.on('pmessage', function (channel, mensage, pattern){
    console.log(channel, mensage, pattern);
  })

}
)

http.listen(3000, function (){
  console.log('Listeining on porta 3000')
})

I already installed the dependencies npm install socket.io ioredis.

Can someone help me.

  • 1

    This error indicates that you are already using the port 3000. Then you can try a) change the port, b) find out the application that is using this port

  • @Sorack, I’m new to Node.js how do I change the port or know what is using the port?

  • 1

    On the line http.listen(3000, function (){ swap the 3000 to another number.

  • @Sorack obg helped me a lot

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.