I have plenty of developer tips that I’ve picked up over the years. They’ve been sitting in my notes, too long for a tweet but too short for a blog post.
So, I’m turning them into a “Dev Tips” series, right from the trenches. First up: killing processes from the command line.
While running processes, especially in VS Code, I often encounter this issue:
This lingers even after I’ve closed all terminal instances.
To cancel any orphaned running processes, use the netstat or lsof commands, depending on your platform.
Windows Command Prompt
netstat -ano | findstr :3000
taskkill /PID <pid> /F
Here, 3000 is the port we are checking, and pid is the process ID returned by the netstat command.
PowerShell (requires elevation)
netstat -a -b -n -o | find "3000"
Stop-Process <pid>
Mac OS
lsof -i :3000
kill -9 <pid>