在 Mac 上查找(并杀死)进程锁定端口 3000 [英] Find (and kill) process locking port 3000 on Mac
问题描述
我如何找到(并杀死)监听/使用我的 tcp 端口的进程?我使用的是 mac os x.
How do I find (and kill) processes that listen to/use my tcp ports? I'm on mac os x.
有时,在崩溃或某些错误之后,我的 rails 应用程序锁定了端口 3000.我无法使用 ps -ef 找到它...
Sometimes, after a crash or some bug, my rails app is locking port 3000. I can't find it using ps -ef...
什么时候做
rails server
我明白
地址已被使用 - bind(2) (Errno::EADDRINUSE)
Address already in use - bind(2) (Errno::EADDRINUSE)
2014 年更新:
完成以下部分答案:执行kill命令后,可能需要删除pid文件rm ~/mypath/myrailsapp/tmp/pids/server.pid
To complete some of the answers below: After executing the kill commands, deleting the pid file might be necessary rm ~/mypath/myrailsapp/tmp/pids/server.pid
推荐答案
你可以试试
netstat
netstat -vanp tcp | grep 3000
对于 macOS El Capitan 和更新版本(或者如果您的 netstat 不支持 -p
),请使用 lsof
>
For macOS El Capitan and newer (or if your netstat doesn't support -p
), use lsof
lsof -i tcp:3000
对于 Centos 7 使用:
netstat -vanp --tcp | grep 3000
这篇关于在 Mac 上查找(并杀死)进程锁定端口 3000的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!