Starting nodejs server on 2 different ports with websocket giving EADDRINUSE 9856 on CentOS

0

I am using 2 different node servers for testing and production on the same computer.
When I start the first server it is running perfectly but when I start the second server it is giving the following error:

events.js:167
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRINUSE :::9856
    at Server.setupListenHandle [as _listen2] (net.js:1327:14)
    at listenInCluster (net.js:1375:12)
    at Server.listen (net.js:1462:7)
    at new WebSocketServer (D:\redheal\chat\node_modules\reload\node_modules\ws\lib\websocket-server.js:68:20)
    at startWebSocketServer (D:\redheal\chat\node_modules\reload\lib\reload.js:109:13)
    at reload (D:\redheal\chat\node_modules\reload\lib\reload.js:99:5)
    at module.exports (D:\redheal\chat\node_modules\reload\index.js:4:10)
    at Object.<anonymous> (D:\redheal\chat\index.js:1185:1)
    at Module._compile (internal/modules/cjs/loader.js:702:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
    at Module.load (internal/modules/cjs/loader.js:612:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
    at Function.Module._load (internal/modules/cjs/loader.js:543:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:744:10)
    at startup (internal/bootstrap/node.js:238:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:572:3)
Emitted 'error' event at:
    at Server.emit (events.js:182:13)
    at emitErrorNT (net.js:1354:8)
    at process._tickCallback (internal/process/next_tick.js:63:19)
    at Function.Module.runMain (internal/modules/cjs/loader.js:746:11)
    at startup (internal/bootstrap/node.js:238:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:572:3)

In this project I am using socket.io, mysql and mongodb connections.

Anji Bandaiah

Posted 2019-01-21T08:22:25.913

Reputation: 1

Answers

0

problem is not with the socket.io it is problem with reload library it using same port for every time. After removing that dependency it is working.

Anji Bandaiah

Posted 2019-01-21T08:22:25.913

Reputation: 1