I have a node.js
application that uses some socket ports. Sometimes, when I exit the application with Ctrl + C
, some kind of node process is left running, still allocating the socket ports. Thus, I cannot restart my application, since it fails to open those ports. When I look the situation with ps
, I get the following response:
我有一个使用一些套接字端口的node.js应用程序。有时,当我使用Ctrl + C退出应用程序时,某些节点进程仍在运行,仍然会分配套接字端口。因此,我无法重新启动我的应用程序,因为它无法打开这些端口。当我用ps查看情况时,我得到以下响应:
$ ps
PID TTY TIME CMD
40454 ttys000 0:00.11 -bash
41643 ttys001 0:00.00 (node)
41741 ttys001 0:00.00 (node)
Trying kill -9 41643
doesn't kill the process. Is it a some kind of unkillable zombie? How can I get rid of those (node)-things blocking my tcp
ports?
尝试杀死-9 41643并不会杀死进程。它是某种无法杀死的僵尸吗?如何摆脱阻塞我的TCP端口的那些(节点)?
2 个解决方案
#1
23
I'm not a MAC user, but here is what I use to kill all the available node processes (under linux):
我不是MAC用户,但这是我用来杀死所有可用的节点进程(在linux下):
sudo killall -9 node
#2
8
On OS X, it's simply:
在OS X上,它只是:
sudo killall -9 node
For a lot of the times, sudo
is overkill, but in your case, it looks like you might want to try sudo
.
在很多时候,sudo是矫枉过正,但在你的情况下,看起来你可能想尝试sudo。
#1
23
I'm not a MAC user, but here is what I use to kill all the available node processes (under linux):
我不是MAC用户,但这是我用来杀死所有可用的节点进程(在linux下):
sudo killall -9 node
#2
8
On OS X, it's simply:
在OS X上,它只是:
sudo killall -9 node
For a lot of the times, sudo
is overkill, but in your case, it looks like you might want to try sudo
.
在很多时候,sudo是矫枉过正,但在你的情况下,看起来你可能想尝试sudo。