Linux and macOS: inspect listeners and their processes
Inspect TCP, UDP and bind addresses with Linux ss or macOS lsof before changing a running service.
Commands inspect their own host or network namespace. Container results are not host results. Examples use TCP 8080 and UDP 53.
1. Linux: use ss
The first query shows TCP listeners and processes; the second checks UDP. Numeric output avoids name resolution. Elevation exposes other users’ process details. UDP is not a TCP LISTEN connection.
sudo ss -ltnp 'sport = :8080'
sudo ss -lunp 'sport = :53'2. macOS: use lsof
Use -sTCP:LISTEN to exclude ordinary TCP connections. Read PID, COMMAND and NAME, distinguishing loopback from all-interface bindings. Do not apply TCP state filters to UDP.
sudo lsof -nP -iTCP:8080 -sTCP:LISTEN
sudo lsof -nP -iUDP:533. Resolve through the owning application
After identifying your application, prefer Ctrl+C or its service manager’s normal stop. SIGKILL skips cleanup and can lose data; do not pipe port discovery into an automatic kill. No result is only a snapshot: the application must still bind successfully.
Sources and review
Sources checked on: