fuser identifies processes using files or sockets. Combined with -k, it kills whatever is holding a port open. Essential for freeing up ports when a dev server crashes without cleaning up.
# Kill whatever is on port 3000
fuser -k 3000/tcp
# Just identify the process (no kill)
fuser 3000/tcp
# Output: 3000/tcp: 12345
# Kill with a specific signal
fuser -k -SIGTERM 3000/tcp
Comparison with alternatives:
# lsof approach (more verbose, more info)
lsof -ti:3000 | xargs kill
# ss + grep approach (most portable)
ss -tlnp | grep :3000
fuser is part of psmisc on most Linux distributions. It is simpler than lsof for the common case of "kill whatever is on this port." The output format (PID/protocol) is also easier to parse in scripts.
On macOS, fuser exists but behaves differently. Use lsof -ti:PORT | xargs kill instead.
The fuser Command Kills Processes on a Port
fuseridentifies processes using files or sockets. Combined with-k, it kills whatever is holding a port open. Essential for freeing up ports when a dev server crashes without cleaning up.Comparison with alternatives:
fuseris part ofpsmiscon most Linux distributions. It is simpler thanlsoffor the common case of "kill whatever is on this port." The output format (PID/protocol) is also easier to parse in scripts.On macOS,
fuserexists but behaves differently. Uselsof -ti:PORT | xargs killinstead.