Rails server says port already used, how to kill that process?
For anyone stumbling across this question that is not on a Mac: assuming you know that your server is running on port 3000, you can do this in one shot by executing the following:
fuser -k 3000/tcp
But as Toby has mentioned, the implementation of fuser in Mac OS is rather primitive and this command will not work on mac.
kill -9 $(lsof -i tcp:3000 -t)
You need to get process id of program using tcp port 3000. To get process id
lsof -i tcp:3000 -t
And then using that process id, simply kill process using ubuntu kill command.
kill -9 pid
Or just run below mentioned combine command. It will first fetch pid and then kill that process.
kill -9 $(lsof -i tcp:3000 -t)
Assuming you're looking to kill whatever is on port 3000 (which is what webrick normally uses), type this in your terminal to find out the PID of the process:
$ lsof -wni tcp:3000
Then, use the number in the PID column to kill the process:
$ kill -9 PID