Why ping misleads in both directions
ICMP lives at the network layer, L3 (ICMP and MTU), while SSH, nginx, PostgreSQL, and APIs run at the
transport and application layers, L4 and L7 (Ports and sockets). A ping result says nothing about
whether a service is healthy:
pingreplies, the site fails to load. The host is up and routing works, yet the app process crashed, a firewall blocks the port, the service listens only on127.0.0.1, or the TLS certificate expired.pingstays silent, the site works. The server’s firewall, router, or cloud load balancer drops inboundICMP Echo Request(Type 8), while TCP443is open and serving traffic.
What to use instead of ping
| What you are checking | Command | What counts as success |
|---|---|---|
| TCP port (SSH, HTTPS, DB) | nc -zv -w 3 203.0.113.10 443 |
Output contains succeeded! (neither refused nor timed out) |
TCP port without nc |
timeout 3 bash -c '</dev/tcp/203.0.113.10/443' && echo OK |
Prints OK (exit code 0) |
| Website and TLS certificate | curl -svI --max-time 5 https://example.org |
Header HTTP/2 200 (or the expected 301/302) |
DNS server (UDP/TCP 53) |
dig @1.1.1.1 +short example.org |
Returns an IP address |
| UDP service (WireGuard, NTP) | The protocol’s own client | UDP has no handshake: silence can mean either DROP or a working service |
ping still earns its place at L3: measure latency and packet loss to the gateway, and probe maximum
unfragmented MTU with -M do -s (MTU blackhole).
How to check
Compare ping against two ports on the same host — open port 22 and closed port 9999:
ping -c 1 127.0.0.1
# 64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.03 ms
nc -zv -w 2 127.0.0.1 22
# Connection to 127.0.0.1 22 port [tcp/ssh] succeeded!
nc -zv -w 2 127.0.0.1 9999
# nc: connect to 127.0.0.1 port 9999 (tcp) failed: Connection refused
Same host, ping succeeds, yet the two ports report opposite states.