Interview Prep/Networking/Sockets, ports, TIME_WAIT and conntrack

A Java service shows `LISTEN *:8080` (or `:::8080`), yet IPv4 clients get `Connection refused` on one host only.

IntermediateTroubleshootingSockets, ports, TIME_WAIT and conntrack
Answer

Likely causes → The app opened an IPv6 socket on ::. Normally that also accepts IPv4 via mapped addresses, but on that host net.ipv6.bindv6only=1 (or the app set IPV6_V6ONLY), so it is IPv6-only. Other hosts have the default 0.

Diagnose →

ss -ltn 'sport = :8080'           # [::]:8080 only, no 0.0.0.0:8080
sysctl net.ipv6.bindv6only
curl -4 -v http://127.0.0.1:8080/ ; curl -6 -v http://[::1]:8080/

Fix → Set net.ipv6.bindv6only=0, or bind the app explicitly to 0.0.0.0 (Java: -Djava.net.preferIPv4Stack=true, Spring: server.address=0.0.0.0), or open both an IPv4 and IPv6 listener.

Prevent → Keep sysctl baselines identical across a fleet and check ss -ltn output in smoke tests.

All Networking questions Roadmap: Networking for DevOps

More on Sockets, ports, TIME_WAIT and conntrack