How to Fix Address Already in Use on Linux
Identify the process listening on a Linux port, distinguish expected services from stale processes, and resolve port conflicts safely.
Address already in use means another socket already occupies the address and port your application wants to bind. The correct fix is to identify its owner—not to kill an arbitrary process by PID.
Identify the listener
Replace 8080 with the affected port:
sudo ss -ltnp 'sport = :8080'
sudo lsof -nP -iTCP:8080 -sTCP:LISTEN
Record the process name, PID, user, and listening address. A listener on 127.0.0.1:8080 has different exposure from one on 0.0.0.0:8080.
Determine how the process is managed
Inspect the process before stopping it:
ps -fp PID
cat /proc/PID/cgroup
It may belong to systemd, Docker, Kubernetes, a process manager, or another developer session. Stop it through its manager so it does not immediately restart.
For systemd:
systemctl status SERVICE
For Docker:
docker ps --filter publish=8080
Choose the correct resolution
Use one of these approaches:
- Stop the old instance if it is stale.
- Change the new application’s configured port.
- Remove a duplicate service definition.
- Correct a container port mapping.
- Bind intentionally to another interface.
Avoid kill -9 as a first response. It prevents graceful cleanup and may leave requests or data incomplete.
Diagnose it with Rumus
Rumus is an AI-native terminal that can investigate the actual Linux host. Its agent reads relevant files, services, logs, processes, and system state, then proposes a reviewable plan before making changes.
What Rumus can inspect
- Services, processes, sockets, and system resources
- Logs, configuration files, permissions, and ownership
- Read-only evidence before cleanup or restarts
Find what owns port 8080 and explain how that process is managed. Check systemd,
containers, and process ancestry. Recommend whether to stop the existing service
or change the new application's port. Do not terminate anything without approval.
Confirm the fix
After applying the chosen change:
sudo ss -ltnp 'sport = :8080'
curl -v http://127.0.0.1:8080/
Confirm both that the intended process owns the port and that the application responds correctly.
Open the server in Rumus and let the AI agent inspect context, propose a plan, and ask before it runs changes.