在端口3000上没有其他进程运行,除了这个
这是程序的一部分
const port = process.env.port || 3000;
app.listen((port), () => console.log(`listening to port ${port}`));
const io = require("socket.io")(port) //Here's the problem.
添加端口3000时出现问题
如果我手动编写像4000这样的其他端口,就会出现。它可以工作
我应该为socket.io创建另一个端口吗?
如属3000港
错误看起来像这个
listening to port 3000
events.js:292
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::3000
Emitted 'error' event on Server instance at:
at emitErrorNT (net.js:1345:8)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
code: 'EADDRINUSE',
errno: -4091,
syscall: 'listen',
address: '::',
port: 3000
}
[nodemon] app crashed - waiting for file changes before starting...
发布于 2021-07-19 19:47:53
在终端中,尝试找到活动端口:
Windows
netstat -ano | findstr :3000
Mac/Linux
lsof -iTCP:3000 -sTCP:LISTEN
然后使用PID杀死:
kill <PID>
如果上面的方法不起作用
kill -9 <PID>
https://stackoverflow.com/questions/68446148
复制相似问题