Run sudo ss -ltnp 'sport = :PORT' to see the process listening on a TCP port (use -lunp for UDP). sudo lsof -i :PORT and sudo fuser PORT/tcp give the same answer. Root is needed to see processes owned by other users.
Symptoms
- A service fails with “Address already in use” or EADDRINUSE
- You need to know what is exposed on a port
- An unexpected port appears in a scan
How to diagnose it
Find the listener with ss
The users: column shows the process name and PID.
sudo ss -ltnp 'sport = :8080' sudo ss -lunp 'sport = :53'Use lsof
Shows listening and connected sockets for the port.
sudo lsof -nP -i :8080Map the PID to a service
Find the systemd unit or container that owns it.
systemctl status PID docker ps --format "{{.Names}} {{.Ports}}"List all listening ports
A quick inventory of what is exposed.
sudo ss -tulpn
Common causes and fixes
An old instance of the same service is still running
Stop it cleanly through systemd.
sudo systemctl stop SERVICEA different service uses the same default port
Change one service’s listen port, or disable the one you do not need.
Docker published the port
docker-proxy owns ports published with -p. Stop the container or change its port mapping.
Socket still closing
Servers should set SO_REUSEADDR; otherwise wait a few seconds after stopping before restarting.
Prevent it happening again
- Statance reports listening ports with their owning process, so new or unexpected listeners are visible.
- Add a TCP port check for services that must stay reachable.
Set it up: TCP port monitoring · Linux monitoring.
FAQ
What replaced netstat -tulpn?
ss -tulpn from iproute2 gives the same output and is installed by default on modern distributions.
How do I kill the process on a port?
sudo fuser -k 8080/tcp kills it, but stopping the owning service with systemctl is safer.
Related guides
Get alerted before this becomes an outage.
Install the agent in one line. Statance watches CPU, memory, disk and services, and its AI assistant helps find the cause.