How to kill a Rails development server by force

Updated . Posted . Visible to the public.

Sometimes, the rails dev server doesn't terminate properly. This can for example happen when the dev server runs in a RubyMine terminal.

When this happens, the old dev server blocks port 3000, so when you try to start a new server, you get the error:

Address already in use - bind(2) for "" port 3000 (Errno::EADDRINUSE)

You can terminate such a dev server with this command:

lsof -t -i :3000 -s TCP:LISTEN | xargs kill -9

It might be worth it to add this to your bash aliases.

Klaus Weidinger
Last edit
Niklas Hasselmeyer
Source code in this card is licensed under the MIT License.
Posted by Klaus Weidinger to makandra dev (2023-01-30 14:16)