在Mac上查找(并杀死)进程,锁定端口3000 [英] Find (and kill) process locking port 3000 on Mac

查看:509
本文介绍了在Mac上查找(并杀死)进程,锁定端口3000的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何找到(并杀死)侦听/使用我的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

推荐答案

  1. 您可以尝试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

    sudo lsof -i tcp:3000 
    

  • 对于 Centos 7 使用

    netstat -vanp --tcp | grep 3000
    

  • 这篇关于在Mac上查找(并杀死)进程,锁定端口3000的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆