How do you find which process is using a port on Linux?
Use ss, lsof, or fuser depending on what is installed.
sudo ss -ltnp | grep ':8080'
sudo lsof -i :8080
sudo fuser -n tcp 8080
- ss -ltnp lists listening TCP sockets with the owning process (-p) and numeric ports (-n). It is the modern replacement for netstat.
- lsof -i :8080 shows open files and sockets for that port.
- fuser -n tcp 8080 prints the PID using the port.
You usually need root or sudo to see processes owned by other users. To identify what a PID is, run ps -fp <pid> or read /proc/<pid>/cmdline. To free the port, stop the process with kill <pid> or, if it ignores SIGTERM, kill -9 <pid>. On systemd hosts, systemctl status can map the process to its unit.