简体   繁体   English

听 EADDRINUSE:地址已被使用 :::5000

[英]listen EADDRINUSE: address already in use :::5000

In my application, I use concurrently to run both backend and front end simultaneously.在我的应用程序中,我同时使用以同时运行后端和前端。 After ctrl + c, strill the port 5000 is running. ctrl + c 后,继续运行 5000 端口。 Also, port 3000 is running.此外,端口 3000 正在运行。 I have to manually kill processes.我必须手动终止进程。 How can I solve this?我该如何解决这个问题?

  1. Run cmd.exe as 'Administrator':以“管理员”身份运行 cmd.exe:

C:\\Windows\\System32>taskkill /F /IM node.exe C:\\Windows\\System32>taskkill /F /IM node.exe

run pa -xa | grep node运行pa -xa | grep node pa -xa | grep node

you will get result with processid你会得到 processid 的结果

4476 pts/0    Sl+    0:01 node index.js

then kill the process with kill -9 4476然后用kill -9 4476进程

as simple as that就如此容易

lsof -ti finds open files(sockets are files in nix based systems) -t removes the headers, so that we can pipe into kill(We just want the process id), -i lets lsof find the file based off the internet address. lsof -ti 查找打开的文件(套接字是基于 nix 的系统中的文件) -t 删除标头,以便我们可以通过管道进入 kill(我们只想要进程 ID), -i 让 lsof 基于 Internet 地址查找文件。 We do not have to provide the full address, we can just search by port, by using the pattern :port.我们不必提供完整的地址,我们可以使用模式:port 按端口搜索。

Some commands accept input from stdin, and we can pipe directly to them, kill is not one of those commands, so we must use xargs(It reads from stdin, and calls the specified command with the input from stdin).有些命令接受来自 stdin 的输入,我们可以直接通过管道传递给它们,kill 不是这些命令之一,所以我们必须使用 xargs(它从 stdin 读取,并使用来自 stdin 的输入调用指定的命令)。

Finally the ;最后; lets us execute both commands irrespective of one another.让我们分别执行这两个命令。 Regardless of whether lsof -ti:3000 |不管 lsof -ti:3000 | xargs kill succeeds or fails, lsof -ti:5000 | xargs kill 成功或失败,lsof -ti:5000 | xargs kill will run, and vice versa. xargs kill 将运行,反之亦然。

lsof -ti:3000 | xargs kill; lsof -ti:5000 | xargs kill

Restart your laptop/server, it will release all the busy ports, then try again... you can also use重启你的笔记本/服务器,它会释放所有繁忙的端口,然后再试一次......你也可以使用

ps aux | grep node

and then kill the process using:然后使用以下命令终止进程:

kill -9 PID..

You can kill all the processes that are using node it can also kill a system process您可以杀死所有使用节点的进程,也可以杀死系统进程

Not preferred: killall -9 node不推荐: killall -9 node

but most of the times it wont work for nodemon, and didnt work for me.但大多数时候它对 nodemon 不起作用,对我也不起作用。

You can fix this issue by killing the address in use or may simply restart your device.您可以通过终止正在使用的地址来解决此问题,也可以简单地重新启动您的设备。

1- For Linux to Kill the address in use, use the following command 1-对于Linux要杀死正在使用的地址,请使用以下命令

sudo kill $(sudo lsof -t -i:8080)

where replace 8080 with your app address.将 8080 替换为您的应用地址。

你可以简单地重新启动你的笔记本电脑或更改它应该工作的端口号

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:监听 EADDRINUSE:地址已在使用:::5000 - Error: listen EADDRINUSE: address already in use :::5000 Nodemon:错误:收听 EADDRINUSE:地址已在使用中:::5000 - Nodemon: Error: listen EADDRINUSE: address already in use :::5000 错误:监听 EADDRINUSE:地址已在使用:::5000 但 dotnet 服务器确实让我在端口 5000 中运行 api - Error: listen EADDRINUSE: address already in use :::5000 BUT dotnet server does let me run api in port 5000 如何修复 EADDRINUSE:地址已在使用中:::5000? - How to fix EADDRINUSE: address already in use :::5000? npm start 出错。 错误:监听 EADDRINUSE:地址已在使用 :::5000 - ERROR with npm start. Error: listen EADDRINUSE: address already in use :::5000 如何修复“错误:监听 EADDRINUSE:地址已在使用中:::5000”未处理的“错误”事件 - How to fix "Error: listen EADDRINUSE: address already in use :::5000" Unhandled 'error' event 在重新启动服务器时出现错误监听 EADDRINUSE: address already in use :::5000 - Got an error listen EADDRINUSE: address already in use :::5000 while restarting a server 错误侦听 EADDRINUSE:地址已被使用 :::19000 - error listen EADDRINUSE: address already in use :::19000 错误:监听EADDRINUSE:地址已在使用3000; - Error: listen EADDRINUSE: address already in use 3000; 听 EADDRINUSE:地址已在使用 0.0.0.0:80 - listen EADDRINUSE: address already in use 0.0.0.0:80
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM