• About
  • Editorial policy
  • Contact
  • Privacy
  • Legal
  • Cookie settings
Monday, November 2, 2026
  • Login
PacketNebula
  • Home
  • News
  • Tools
    • Network
    • Security
    • Developer
    • Sysadmin
    • SEO
    • Email & DNS
  • Guides
  • Trackers
    • LLM API pricing
    • Open-weight models
    • Retirements calendar
    • Infrastructure deals
  • About
  • Download
No Result
View All Result
PacketNebula
No Result
View All Result
Home Sysadmin

How to kill the process using a port on Linux

by Stéphane Cardon
3 September 2026
in Sysadmin
0
Netgear 5-port gigabit Ethernet switch with a yellow and a red cable plugged into its ports

Image: Simon A. Eugster / Wikimedia Commons, CC BY-SA 3.0

Share on FacebookShare on Twitter

Your server won't start and the terminal throws 'address already in use'. Something's squatting on that port, and sudo lsof -i :8080 (or ss -ltnp on a leaner box) tells you what: the PID column is your culprit. We send a polite kill PID first and keep kill -9 for the ones that ignore us. Below: how to read the lsof output, why SIGTERM comes before SIGKILL, a fuser one-liner that finds and kills in one shot, plus what's actually going on when the port looks busy but lsof shows nothing at all.

The short answer

sudo lsof -i :8080 (or ss -ltnp) shows the PID holding the port. kill 4821 asks it nicely; kill -9 4821 is for when it won’t listen. The “address already in use” error clears the moment the process exits.

lsof -ifind the PID
kill / -9gentle, then forced
fuser -kthe one-liner
Answer card showing sudo lsof -i :8080 to find the PID on a port, then kill to free it, on Linux.
Find the PID, stop it gently, force it only if you must.

Find the PID, then stop it cleanly

Linux
sudo lsof -i :8080

The PID column is the one we’re after. No lsof on this box? sudo ss -ltnp | grep :8080 does the same job, and sudo fuser 8080/tcp prints just the PID, nothing else.

Linux
kill 4821

Plain kill sends SIGTERM. That’s a request: the process gets to close its files and release the port properly. Give it a second, then re-run the lsof from Step 1 to check it’s gone.

Force it only when needed, and the one-liner

Still holding the port after SIGTERM? Escalate:

Linux
kill -9 4821

kill -9 sends SIGKILL, which can’t be caught or ignored. The process dies on the spot with zero chance to clean up, which is exactly why we keep it as the last resort and not the opening move.

Terminal showing sudo lsof -i :8080 finding node on PID 4821, then kill 4821 and kill -9 4821 as a fallback.
lsof to find it, kill to stop it, kill -9 only when it digs in.

Once you’re sure what’s sitting on the port, one command does the find and the kill:

Linux
sudo fuser -k 8080/tcp

Prefer lsof? sudo kill -9 $(sudo lsof -t -i:8080) does the same thing.

When lsof shows nothing

Port looks busy, lsof comes back empty. Two usual suspects. The socket may be sitting in TIME_WAIT, cooling down after a close; no process holds it, and it frees itself shortly. Or the owner runs as root and you forgot sudo, so you just couldn’t see it. In our experience it’s the missing sudo most of the time.

On Windows instead? The tools are netstat and taskkill: see how to kill the process using a port on Windows.

When lsof or ss shows a port in use but no process name, you’re almost always missing privileges or looking from outside a container.

Both tools only reveal the owning process for processes you own, so a service running as another user shows the port and a blank command until you add sudo. That one catches people constantly, because the port line appears and the process column doesn’t, which looks like a bug rather than a permission.

The container case is different in kind. A process inside a container lives in its own PID namespace, so from the host you see the published port bound by the container runtime rather than by the application. Killing what the host shows you takes down the wrong thing. Find the container with docker ps, stop it properly, and leave the runtime alone.

Frequently asked questions

How do I find which process is using a port on Linux?

Run "sudo lsof -i :8080" and read the PID column: that's the program bound to the port. No lsof on the box? "sudo ss -ltnp | grep :8080" does the same job, and "sudo fuser 8080/tcp" prints just the PID.

What’s the difference between kill and kill -9?

Plain kill sends SIGTERM, a polite request to shut down cleanly and free its resources. kill -9 sends SIGKILL, which the process can't catch or ignore: it dies instantly but gets no chance to clean up. We always try SIGTERM first.

Why do I need sudo to kill the process?

Only when the process runs under another user or as root, which many services do. Then you can't see or kill it without elevated rights. A process you started yourself doesn't need sudo.

Is there a one-liner to free a port?

Yes: "sudo fuser -k 8080/tcp" finds and kills whatever holds the port in one command. "sudo kill -9 $(sudo lsof -t -i:8080)" does the same with lsof. Save them for ports where you're sure what's running.

Tags: guidelinuxports
ShareTweet
Previous Post

How to kill the process using a port on Windows

Next Post

How to generate an SSH key (ssh-keygen)

Stéphane Cardon

Stéphane Cardon

Network cybersecurity engineer: architecture, LAN and WLAN, system administration. He runs PacketNebula, where he publishes the tools and answers he wanted for his own work.

Next Post
Close-up of a metal door key on a keyring against a black background

How to generate an SSH key (ssh-keygen)

Free tools

  • IPv4 subnet calculator
  • DNS lookup
  • SSL certificate checker
  • HTTP headers checker
  • SPF, DKIM and DMARC checker
  • JWT decoder
  • Cron expression builder
  • Chmod calculator
  • Password generator

All 24 tools →

Guides to keep handy

  • Flush the DNS cache on Windows
  • Kill the process using a port
  • Generate an SSH key
  • Secure a new Ubuntu VPS
  • Find files on Linux
  • Extract and create tar.gz

More guides →

Who writes this

Stéphane Cardon, network cybersecurity engineer. Architecture, LAN and WLAN, system administration. PacketNebula holds the tools and answers he wanted for his own work.

About this site →

  • About
  • Editorial policy
  • Contact
  • Privacy
  • Legal
  • Cookie settings

Copyright © 2026 Stephane Cardon.

No Result
View All Result
  • Home
  • News
  • Tools
    • Network
    • Security
    • Developer
    • Sysadmin
    • SEO
    • Email & DNS
  • Guides
  • Trackers
    • LLM API pricing
    • Open-weight models
    • Retirements calendar
    • Infrastructure deals
  • About
  • Download

Copyright © 2026 Stephane Cardon.

Cookies, your call

We use Google Analytics to see which pages get read. Once our AdSense application is approved, articles and guides will carry Google ads. Nothing runs until you say yes, and nothing runs on the tool pages. Details