Monday 4 December 2017

macos - Find (and kill) process locking port 3000 on Mac

itemprop="text">

How do I find (and kill) processes
that listen to/use 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...



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



Answer





  1. You can try
    netstat



    netstat
    -vanp tcp | grep
    3000

  2. For
    macOS El Capitan and newer (or if your netstat doesn't
    support -p), use
    lsof




    sudo
    lsof -i tcp:3000


  3. For
    Centos 7
    use



    netstat -vanp --tcp | grep
    3000



No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...