Kill A Ghost Process

Reference

There is something that came up when I was helping with a workshop at Codeland: remembering how to find and kill a ghost process running on a machine.

Example: trying to run a server on a certain port, and it’s unable to because there is already a process running on that server. But I don’t have any terminal windows open, how the heck do I find it! Or I accidentally closed the window running a database server daemon. Yikes!

I’ve run across this more than once, so once and for all, for easy access and reference:

$ lsof -i :PORT_NUMBER
$ kill -9 <PID>

If permissions prove to be an issue, use sudo with care.

Note to future self: you’re welcome.