Find and Kill Process Locking 3000 Port

Sometimes, after a crash or some bug or sometime by mistake we forcefully shut down the rails server using Ctrl + Z. After that when we try again to run rail s it gives some error like

Address already in use - bind(2) (Errno::EADDRINUSE)

We can kill the process blocking the port 3000 simply by putting the following code in terminal.

kill -9 $(lsof -i tcp:3000 -t)

Also, we can use (doesn’t work wih MAC)

fuser -k 3000/tcp

We can also create alias to ‘k3000’ in ~/.bash_aliases to kill server in case we don’t remember the command. Happy Coding :)