Apr 4 2023

Kill a Stray Process on Linux Using `lsof`

Sometimes local servers get naughty and fail to exit with a signal. They end up occupying a port, and that isn't very pleasant. Here's how to kill them using lsof.

#linux · 1-minute read
Last updated: Tuesday, April 4th, 2023
  1. Find out what process is running on the port:
    Terminal window
    1
    lsof -i:<port>
  2. Copy the process number from the PID column.
  3. Kill the process:
    Terminal window
    1
    kill -9 <process-number>
  4. Confirm that the process has closed by re-running the command at step 1.

Explore by Tag

On each tag page, you can find a link to that tag's RSS feed so you only get the content you want.