anishkhatri@Anishs-MacBook-Pro TrainerRoomProject-main % npm run server
[email protected] server nodemon server.js
[nodemon] 2.0.16
[nodemon] to restart at any time, enter rs
[nodemon] watching path(s): .
[nodemon] watching extensions: js,mjs,json
[nodemon] starting node server.js
(node:77344) [MONGODB DRIVER] Warning: Current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
(Use node --trace-warnings ...
to show where the warning was created)
node:events:505
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::5000 at Server.setupListenHandle [as _listen2] (node:net:1372:16) at listenInCluster (node:net:1420:12) at Server.listen (node:net:1508:7) at Function.listen (/Users/anishkhatri/Downloads/TrainerRoomProject-main/node_modules/express/lib/application.js:635:24) at Object. (/Users/anishkhatri/Downloads/TrainerRoomProject-main/server.js:41:5) at Module._compile (node:internal/modules/cjs/loader:1105:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12) at node:internal/main/run_main_module:17:47 Emitted 'error' event on Server instance at: at emitErrorNT (node:net:1399:8) at processTicksAndRejections (node:internal/process/task_queues:83:21) { code: 'EADDRINUSE', errno: -48, syscall: 'listen', address: '::', port: 5000 } [nodemon] app crashed - waiting for file changes before starting...
CodePudding user response:
First install kill-port package globally
npm i -g kill-port
After installing the package run this command to kill the port
npx kill-port 5000
CodePudding user response:
Address that your're trying to use is already in use. Try:
lsof -i:5000 // or another port
// this command will give ids of processes running on a certain port
kill -9 [process]