How do I find processes that listens to/uses my tcp ports? I'm on mac os x.
Sometimes, after a crash or some bug, my rails app is locking port 3000. I can't find it using ps -ef... How do I find the stupid thing and kill it, brutally... ?
When doing
rails server
I get
Address already in use - bind(2) (Errno::EADDRINUSE)
2014 update:
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
Using sindresorhus's fkill tool, you can do this:
Step 1: Find server which are running:
ps aux | grep puma
Step 2: Kill those server Kill -9 [server number]In your
.bash_profile
, create a shortcut forterminate
the 3000 process:Then, call
$terminate
if it's blocked.This single command line is easy to remember:
npx kill-port 3000
For a more powerful tool with search:
npx fkill-cli
PS: They use third party javascript packages
Sources: tweet | github
Find the open connection
Kill by process ID
To view the processes blocking the port:
netstat -vanp tcp | grep 3000
To Kill the processes blocking the port:
kill $(lsof -t -i :3000)