0
//code const express = require('express') const app = express() const server = require('http').Server(app) const io = require('socket.io')(server) const { v4: uuidv4 } = require('uuid')

app.set('view engine', 'ejs') app.use(express.static('public'))

app.get('/',(req, res) =>{ res.redirect(/${uuidv4()}) })

app.get('/:room', (req, res) =>{ res.render('room', {roomId: req.params.room }) })

io.on('connection',socket =>{ socket.on('join room',(roomId, userId) =>{ console.log(roomId,userId) }) })

server.listen(3000)

// Error

[nodemon] 2.0.4 [nodemon] to restart at any time, enter rs [nodemon] watching path(s): . [nodemon] watching extensions: js,mjs,json [nodemon] starting node server.js events.js:292 throw er; // Unhandled 'error' event ^

Error: listen EADDRINUSE: address already in use :::3000 at Server.setupListenHandle [as _listen2] (net.js:1313:16) at listenInCluster (net.js:1361:12) at Server.listen (net.js:1447:7) at Object. (I:\Volume E\zoom-clone\server.js:25:8) at Module._compile (internal/modules/cjs/loader.js:1138:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10) at Module.load (internal/modules/cjs/loader.js:986:32) at Function.Module._load (internal/modules/cjs/loader.js:879:14) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) at internal/main/run_main_module.js:17:47 Emitted 'error' event on Server instance at: at emitErrorNT (net.js:1340:8) at processTicksAndRejections (internal/process/task_queues.js:84:21) { code: 'EADDRINUSE', errno: 'EADDRINUSE', syscall: 'listen', address: '::', port: 3000 } [nodemon] app crashed - waiting for file changes before starting...

Aman Kumar
  • 4,096
  • 2
  • 13
  • 37
  • Does this answer your question? [How to fix Error: listen EADDRINUSE while using nodejs?](https://stackoverflow.com/questions/9898372/how-to-fix-error-listen-eaddrinuse-while-using-nodejs) – Anurag Srivastava Aug 11 '20 at 07:33
  • It just means something else is already listening to port 3000 and hence you can't use `server.listen(3000)` for this. Try changing 3000 to some other number it should work. Or check the answer @AnuragSrivastava just mentioned. – keidakida Aug 11 '20 at 07:34
  • if it doesn't matter what is running, then I would suggest to kill the service running on this port. – Prabhat Mishra Nov 11 '20 at 11:45

1 Answers1

0

This error means the 3000 port already in use, refer the below answer

How to fix Error: listen EADDRINUSE while using nodejs?

In my case, I started the application in debug mode, which was using the port 3000, after that I faced this issue. I resolved this issue by reboot, which is not a correct way. I recommends the above answer.

Mahesh
  • 71
  • 5