ruby-on-railscloud9-idewebrick

Address already in use - bind(2) when starting server in Cloud9 IDE


When starting the server in Cloud9, rails s -p $PORT -b $IP, I get an error and the server fails to start.

Address already in use - bind(2)

Following this post, Rails server says port already used, how to kill that process?,

I ran lsof -wni tcp:8080 (8080 because of cloud9)

COMMAND   PID   USER   FD   TYPE    DEVICE SIZE/OFF NODE NAME
ruby 18415 ubuntu    9u  IPv4 698526934      0t0  TCP *:http-alt (LISTEN)

Then,

kill -18415 PID

But this results in an error,

bash: kill: 18415: invalid signal specification

Can anyone advise how to fix this error on Cloud9?


Solution

  • You're killing it with the wrong way. You need to use:

    kill -9 18415
    

    9 - signal 'kill'
    18415 - process id

    Also you can kill all ruby processes like this:

    killall -9 ruby
    

    But use it only when you know what you're doing.