Find and Kill a Process on a Specific Port on macOS
March 26, 2020
TLDR
1.sudo lsof -i :<PortNumber>2.3.kill -9 <PID>
Find out what is running on a particular port on macOS
You can find out what is running on a specific port by running the command lsof -i with the port number, :<PortNumber>.
1.sudo lsof -i :<PortNumber>
Example
1.> sudo lsof -i :80002.3.COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME4.node 24922 cody 79u IPv4 0x4d990156241107c9 0t0 TCP localhost:irdmi->localhost:60453 (ESTABLISHED)
Kill the process running on a specific port on macOS
We can use the kill command with the -9 option and the port PID number to kill a process on macOS. Use the command above, lsof -ito find the PID for the port you want to kill.
1.kill -9 <PID>
Example
In the above example there is a process on port 8000 with a PID that equals 24922. So we can kill that process using the following command:
1.kill -9 24922
Which won't have any output, but if you were running a server on that port in another terminal window then you can usually see that the process was killed.
1.zsh: killed npm start
Popular Articles
I Can't Believe It's Not CSS: Styling Websites with SQL
Style websites using SQL instead of CSS. Database migrations for your styles. Because CSS is the wrong kind of declarative.

How I Built an Oreo Generator with 1.1 Sextillion Combinations
Building a web app that generates 1,140,145,285,551,550,231,122 possible Oreo flavor combinations using NestJS and TypeScript.

AI Model Names Are The Worst (tier list)
A comprehensive ranking of every major AI model name, from the elegant to the unhinged. Because apparently naming things is the hardest problem in AI.