shou2017.com
JP

How to Stop Rails Server When You Forget to Terminate 'rails s' in Terminal

Sun Apr 15, 2018
Sat Aug 10, 2024

I wanted to master using Rubymine shortcuts elegantly, and while testing and running bundle install, I forgot to stop rails s.

Normally, you can terminate it by pressing Control + C in the terminal, but since I had already closed the terminal, I couldn’t do anything. I thought there might be a good way to handle this in Rubymine, but there was no such convenient solution. I ended up stopping the server from the terminal as usual.

Steps

$ lsof -i :3000
COMMAND  PID USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
ruby    3493 boku   19u  IPv4 0x7d113ea5337c08c9      0t0  TCP *:hbci (LISTEN)
ruby    3494 boku   19u  IPv4 0x7d113ea5337c08c9      0t0  TCP *:hbci (LISTEN)
$ kill 3493
$ kill 3494

The lsof command displays information about open files based on port, PID, or process name.

See Also