1

I'm trying to run rails server to start a local server but got this error

...
WARN  TCPServer Error: Address already in use - bind(2)
Exiting
...

So I went and looked for the process that was occupying the port and killed it. The server still wouldn't start. And as it turned out, lsof still showed the process (even after it had been killed):

$ lsof -P | grep ':3000' 
ruby      52944 user    7u    IPv4 0xffffff800bdafbd8       0t0      TCP *:3000 (LISTEN)
$ kill 52944    <<<<<<< pid 52944 should have died here!
$ lsof -P | grep ':3000' 
ruby      52944 user    7u    IPv4 0xffffff800bdafbd8       0t0      TCP *:3000 (LISTEN)

Any idea how to really kill the process?

(This is on OSX)

user1508893
  • 9,223
  • 14
  • 45
  • 57
  • 3
    kill -9 (and three more chars to make a comment..) – thebjorn Feb 23 '13 at 21:40
  • @thebjorn - Make this an answer. – Douglas F Shearer Feb 23 '13 at 21:41
  • @thebjorn Yeah! Thanks! (Why is `-9` necessary?) – user1508893 Feb 23 '13 at 21:42
  • 1
    I never remember exactly what the different signals are, I just think of `kill ` as "can you please stop this process" and `kill -9 ` as "kill this process.. now!" :-) – thebjorn Feb 23 '13 at 21:45
  • 1
    By default, `kill` sends the TERM signal. Normally, this kills the process; but if the process has a handler defined for TERM, it will be run (the idea is to allow the process to clean up before exiting). If the process decides to, it can even ignore the TERM signal. `kill -9`, on the other hand, sends the KILL signal, which cannot be caught or ignored. – Gordon Davisson Feb 23 '13 at 22:13

1 Answers1

5

Use

kill -9 <id>

to kill stubborn processes :-)

thebjorn
  • 26,297
  • 11
  • 96
  • 138