Has it ever happened to you? You attempt to boot up a server instance in the language of your choice (Javascript, Ruby, Python) and you get an error:
Error: A server is already running!
Not too much a problem, you probably just forgot to properly shutdown your server last time you were workring on your personal project. On your local machine the work of finding the still running process isn't too difficult. If you use a Mac like me, you can simply check through the open terminal instances you have running as most manual processes shutdown when you close your terminal.
But maybe you're not trying to boot up a server on your local machine, maybe your server lives in a warehouse of physical servers somewhere very far away on a cloud hosting platform like Heroku or AWS EC2. Worse still, you can't just look in your code and see which port number your server listens to because your software's port is randomly assigned by your cloud hosting provider!
Not to fear!
In many cases you can manually find the port number where you're mysterious process is running and shut it down!
If you suspect you know the number of the port you can run the commands:
lsof -i:<port number>
^To see what process is running on that port.
kill <process id>
^And this to request that process ends gracefully.
Or you can combine the two:
kill $(lsof -t -i :YOUR_PORT_NUMBER)
If you want the process to end immediately and without being able to clean up after itself you can run the following commands:
kill -kill $(lsof -t -i :YOUR_PORT_NUMBER)
or
kill -9 <process id>