“While executing an express application it crashed.”

huangapple go评论71阅读模式
英文:

While executing an express application it crashed

问题

node .\\index.js
node:events:490
throw er; // 未处理的 'error' 事件
^

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
英文:
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 !");
});

答案1

得分: 1

答案在问题中。

错误:监听EADDRINUSE:地址已在使用中 :::3000

端口3000已被占用。
在运行Express或任何使用3000端口的应用程序之前,您需要终止该端口的所有进程。

对于Windows

找到您的进程的PID。

netstat -aon | findstr 3000

它将会响应如下消息

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

然后终止进程

taskkill /f /pid 2980
英文:

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

答案2

得分: 0

确保你的端口3000可用,或尝试在不同的端口上运行。

英文:

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

huangapple
  • 本文由 发表于 2023年4月17日 15:21:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/76032584.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定