[英]ERROR with npm start. Error: listen EADDRINUSE: address already in use :::5000
this may be the exact same problem for me: MongoDB/React Error: listen EADDRINUSE: address already in use :::5000这对我来说可能是完全相同的问题: MongoDB/React Error: listen EADDRINUSE: address already in use :::5000
I tried the method "npx kill-port 5000", and it says "Process on port 5000 killed".我尝试了“npx kill-port 5000”方法,它显示“进程在端口 5000 上被杀死”。 However, I run "npm start" again, it just gives me the same error.
但是,我再次运行“npm start”,它只是给了我同样的错误。
here's my server index.js这是我的服务器 index.js
import express from "express";
import bodyParser from "body-parser";
import mongoose from "mongoose";
import cors from "cors";
const app = express();
app.use(bodyParser.json({ limit: "30mb", extended: true }));
app.use(bodyParser.urlencoded({ limit: "30mb", extended: true }));
app.use(cors());
const CONNECTION_URL = 'mongodb+srv://weiz:123456wz@cluster0.s6fc6.mongodb.net/?retryWrites=true&w=majority';
const PORT = process.env.PORT || 5000;
mongoose.connect(CONNECTION_URL, { useNewUrlParser: true, useUnifiedTopology: true })
.then(() => app.listen(PORT, () => console.log("Server running on port: 5000"))) //useless
.catch((error) => console.log(error.message));
mongoose.connect(CONNECTION_URL).then(() => { console.log('...') });
here's my error这是我的错误
apple@3 server % npm start
> server@1.0.0 start
> nodemon index.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 index.js`
...
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/apple/Desktop/memories_project/server/node_modules/express/lib/application.js:635:24)
at file:///Users/apple/Desktop/memories_project/server/index.js:23:21
at processTicksAndRejections (node:internal/process/task_queues:96:5)
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...
if more codes need to be provided, I will add them.如果需要提供更多代码,我会添加它们。
I finally solved this by updating my mac system.我终于通过更新我的mac系统解决了这个问题。 I think there must be some problem with my airplay function in the old system version
我想我在旧系统版本中的播放功能肯定有问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.