Skip to content
Latchkey

ping Command Reference: Flags, Usage & CI Examples

ping tests host reachability with ICMP echo requests.

ping sends ICMP echo requests and reports replies and round-trip times. It is a fast reachability and latency check, with the caveat that many networks block ICMP.

Common flags and usage

  • -c <N>: send N packets then stop (always use in CI)
  • -W <secs>: per-reply timeout
  • -i <secs>: interval between packets
  • -w <secs>: overall deadline
  • -q: quiet summary output only

Example

shell
ping -c 3 -W 2 db.internal.example.com || echo "host unreachable or ICMP blocked"

In CI

Always bound ping with -c so it does not run forever. A failed ping does not always mean the service is down -- many hosts and cloud networks block ICMP while serving TCP fine, so use nc -z for an actual port check.

Key takeaways

  • ping checks reachability and latency via ICMP.
  • Always use -c to bound the packet count in CI.
  • ICMP is often blocked, so prefer nc -z for service checks.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →