Some features on the way are: next available port; wait (wait for a host to return a successful health check before proceeding - good for migrations etc.). And lots more. It's not just about listing running ports, but a tool for managing them.
But to each their own, that's what's lovely about the many options available. But if you have anything in relation to this you think is neat, feel free to open an issue. It may be able to convince you that a simple alias won't suffice.
3000 wud (getwud/wud:latest) wud getwud/wud:latest 3000 http://localhost:3000
3001 dockhand (fnsys/dockhand:latest) dockhand fnsys/dockhand:latest 3000 http://localhost:3001 lk() {
if [ $# -eq 0 ]; then
local output=$(sudo lsof -iTCP -sTCP:LISTEN -n -P)
elif [ $# -eq 1 ]; then
local output=$(sudo lsof -iTCP -sTCP:LISTEN -n -P | grep -i --color=always $1)
else
echo "find and kill processes listening on ports. Usage: lk [pattern]"
return 1
fi
if [ -z "$output" ]; then
echo "No listening processes found."
return 0
fi
# Show header + results
echo "$(sudo lsof -iTCP -sTCP:LISTEN -n -P | head -1)"
echo "$output"
echo ""
# Extract unique PIDs (skip the header row if no grep was applied)
local pids=($(echo "$output" | awk '{print $2}' | grep -E '^[0-9]+$' | sort -u))
if [ ${#pids[@]} -eq 0 ]; then
echo "No PIDs found."
return 0
fi
echo "PIDs to kill: ${pids[*]}"
echo -n "Kill these ${#pids[@]} process(es)? [y/N] "
read -r confirm
if [[ "$confirm" =~ ^[Yy]$ ]]; then
for pid in "${pids[@]}"; do
echo "Killing PID $pid..."
sudo kill -9 $pid
done
echo "Done."
else
echo "Aborted."
fi
}For the even less patient there's also this (not mine): https://github.com/jkfran/killport
https://github.com/clutchski/dotfiles/blob/main/home/bin/por...
raskrebs•4h ago
So I built this lightweight CLI. Single binary, no dependencies. It shows everything listening on localhost with process names, Docker container info, clickable URLs etc.
Sure there are workarounds, but none that satisfied my need for a short, easily rememberable command. Also nothing really has the same satisfaction as running sonar kill 3000 — it just feels nice. I’ve already been approached by a few agent orchestration tools that have been struggling with the same thing. It's really useful when you have multiple agents running, but it's not built for just that use case, I have also find it handy when killing off all containers after a failed cleanup and so on. Also know that MCPs are dead and CLIs are the new thing in agentic coding, this might be a useful tool for Claude, particularly when a compose process exits before all containers are stopped.
Open for contributions, ideas and feedback.
pluc•1h ago
raskrebs•1h ago
embedding-shape•1h ago
Wow, this says more about the agent orchestration tool ecosystem than what you might think, that they're unable to kill child processes they themselves spawn makes it seem like they have zero clue about what they're doing.
Probably why my impression always end up with "Wow, what a vibe-coded mess" when I look through the source of all these harnesses, they don't seem engineered at all.