Ever get this error?
[11:54:49] (master) playlister-sinatra-ruby-007
== Shotgun/Thin on http://127.0.0.1:9393/
Thin web server (v1.6.3 codename Protein Powder)
Maximum connections set to 1024
Listening on 127.0.0.1:9393, CTRL+C to stop
/Users/casielevine/.rvm/gems/ruby-2.2.0/gems/eventmachine-1.0.7/lib/eventmachine.rb:526:in `start_tcp_server’: no acceptor (port is in use or requires root privileges) (RuntimeError)
While running a Sinatra application, I’m attempting to run the shotgun command and the terminal is telling me the “port is in use”. This error is caused by closing the terminal without killing the server first.
I’ve gotten this error numerous times. Unfortunately, CTRL+C doesn’t actually work. How do we handle this?
There’s a pretty easy hack. Enter “ps aux | grep ruby” in your command line. The terminal comes back at you with a bunch of data.
[11:54:54] (master) playlister-sinatra-ruby-007
♥ ps aux | grep ruby
casielevine 817 0.0 0.3 2479892 24324 ?? S 9:45AM 0:01.59 ruby /Users/casielevine/.rvm/gems/ruby-2.2.0/bin/shotgun
casielevine 1734 0.0 0.0 2423356 24 s000 R+ 11:55AM 0:00.00 grep ruby
Next, type in “kill -9”, then the first digits that show up in the line with the ?? S value.
[11:55:29] (master) playlister-sinatra-ruby-007
♥ kill -9 817
After entering this, you should have no pushback. This should solve the issue!
For more information, check out the link below: