Port check: who listens, can I connect, is it blocked?
Read-onlyPaste a port number. Shows the process listening on it, connections by state, a local connection test, firewall rules mentioning it and Docker containers publishing it.
(
PORT="<port>"
h() { printf '\n=== %s ===\n' "$*"; }
h "What listens on port $PORT"
sudo ss -tulpn "sport = :$PORT" 2>/dev/null
h "That process"
for pid in $(sudo ss -tulpnH "sport = :$PORT" 2>/dev/null | grep -o 'pid=[0-9]*' | cut -d= -f2 | sort -u); do
ps -o pid,user,etime,cmd -p "$pid" | cut -c1-160
systemctl status "$pid" --no-pager 2>/dev/null | head -1
done
h "Connections by state"
ss -tanH "( sport = :$PORT or dport = :$PORT )" | awk '{print $1}' | sort | uniq -c
h "Local connection test"
timeout 3 bash -c "echo > /dev/tcp/127.0.0.1/$PORT" 2>/dev/null && echo "127.0.0.1:$PORT accepts connections" || echo "127.0.0.1:$PORT refused or timed out"
curl -sS -m 5 -o /dev/null -w "HTTP %{http_code} in %{time_total}s\n" "http://127.0.0.1:$PORT/" 2>&1 | head -1
h "Firewall rules mentioning $PORT"
sudo ufw status 2>/dev/null | grep -w "$PORT"
sudo firewall-cmd --list-ports 2>/dev/null | tr ' ' '\n' | grep -w "$PORT"
sudo iptables -S 2>/dev/null | grep -w "$PORT"
sudo nft list ruleset 2>/dev/null | grep -w "dport $PORT"
h "Docker containers publishing $PORT"
command -v docker >/dev/null && docker ps --filter publish="$PORT" --format 'table {{.Names}}\t{{.Ports}}' 2>/dev/null
) 2>&1 | tee "debug-port-$(date +%Y%m%d-%H%M%S).txt"What it checks
What listensTCP/UDP sockets on the port and the owning process (0.0.0.0 = all interfaces, 127.0.0.1 = local only)That processcommand line, user, how long it runs, and its systemd unitConnections by stateESTAB, TIME-WAIT, CLOSE-WAIT counts (lots of CLOSE-WAIT = app not closing connections)Local testraw TCP connect plus an HTTP request to localhostFirewallufw, firewalld, iptables and nftables rules for the portDockercontainers that publish this port on the host