The Old Way vs The New Way
# The lsof ritual (every developer knows this pain):
$ lsof -i :3000
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
node 84921 user 23u IPv6 0x... 0t0 TCP *:3000 (LISTEN)
$ kill -9 84921
# Was that safe? Who knows. Did it work? Check again.
$ lsof -i :3000
# OK, port is free. Now restart manually.
# The portrm way:
$ ptrm fix 3000 --run "npm run dev"
# Done. Identified, safety-checked, killed, restarted.
Comparison
| Capability | lsof + kill | portrm |
|---|---|---|
| Find process on port | lsof -i :3000 | ptrm 3000 |
| Kill process | kill -9 PID | ptrm fix 3000 |
| Steps required | 3+ commands | 1 command |
| Service identification | Process name only | Full service type + confidence |
| Safety checks | None | 3-tier system |
| Graceful shutdown | Manual (kill vs kill -9) | Automatic SIGTERM escalation |
| Readable output | Cryptic columns | Human-readable table |
| Auto-restart | No | --run flag |
| Multiple ports | Separate commands each | ptrm fix 3000 8080 -y |
| Works on Windows | No (use netstat) | Yes, cross-platform |
| Scan all ports | lsof -i -P -n (messy) | ptrm scan |
What You Actually Want to Know
lsof output is unreadable
lsof -i :3000 shows cryptic columns like FD, TYPE, DEVICE, SIZE/OFF that most developers never need. portrm shows what matters: the service name, memory usage, uptime, and whether it is safe to kill.
kill -9 is dangerous
When you kill -9 a process, it gets no chance to clean up. For a Node.js dev server, this is fine. For PostgreSQL, this can corrupt your database. You have to know the difference. portrm knows the difference for you.
Cross-platform pain
lsof works on macOS and Linux. On Windows, you need netstat -ano | findstr. On Linux, you might use ss or fuser. portrm uses the same command everywhere: ptrm fix 3000.
No restart
After killing with lsof + kill, you manually go back to your terminal and type the start command. portrm does it in one step: ptrm fix 3000 --run "npm run dev".
When to Still Use lsof
lsof is a general-purpose tool. Use it when you need:
- To inspect file descriptors (not just network ports)
- Low-level socket debugging
- To list all open files for a specific process
For port management, portrm is the better tool.
Replace the lsof ritual
One command instead of three. Safety included.