-2
node .\\index.js
node:events:490
throw er; // Unhandled 'error' event
^

Error: listen EADDRINUSE: address already in use :::3000
at Server.setupListenHandle \[as \_listen2\] (node:net:1774:16)
at listenInCluster (node:net:1822:12)
at Server.listen (node:net:1910:7)
at Function.listen (D:\\Gamaca AI\\Express2\\node_modules\\express\\lib\\application.js:635:24)
at Object.\<anonymous\> (D:\\Gamaca AI\\Express2\\index.js:9:5)
at Module.\_compile (node:internal/modules/cjs/loader:1275:14)
at Module.\_extensions..js (node:internal/modules/cjs/loader:1329:10)
at Module.load (node:internal/modules/cjs/loader:1133:32)
at Module.\_load (node:internal/modules/cjs/loader:972:12)
at Function.executeUserEntryPoint \[as runMain\] (node:internal/modules/run_main:83:12)
Emitted 'error' event on Server instance at:
at emitErrorNT (node:net:1801:8)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
code: 'EADDRINUSE',
errno: -4091,
syscall: 'listen',
address: '::',
port: 3000
}

Node.js v19.8.1
$ node index.js

We tried to execute from this command.

Check it Out the code !
const express = require('express');
const app = express();

app.get('/', (res, req) => {
  res.send("Hello Rushikesh! ");
});

app.listen(3000, () => {
  console.log("App is lodding in Port no 3000 !");
});
Phil
  • 157,677
  • 23
  • 242
  • 245

2 Answers2

1

The answer is in question.

Error: listen EADDRINUSE: address already in use :::3000

The port 3000 already in use. You need to kill all process for this port before running your express or any app which use 3000 port.

For windows

Find PID of your process.

netstat -aon | findstr 3000

It will reponse like this message

  TCP    0.0.0.0:3000          0.0.0.0:0              LISTENING       2980
  TCP    [::]:3000             [::]:0                 LISTENING       2980

then kill process

taskkill /f /pid 2980
yasintuncel
  • 76
  • 1
  • 4
0

Make sure your port 3000 is available or try to run it on a different port.

Dev Gaud
  • 676
  • 6
  • 10