Skip to content

Connectivity Diagnostic

The connectivity diagnostic walks through network layers from local network to TLS, running checks at each level to pinpoint where connectivity breaks. It produces a structured report with [PASS], [FAIL], and [WARN] indicators across seven sections:

  1. Local Network — Can we detect our own IP and default gateway?
  2. DNS Resolution — Does the target domain resolve to an IP?
  3. ICMP Reachability — Can we ping the target?
  4. TCP Port Connectivity — Are ports 80 and 443 open?
  5. HTTP/HTTPS Response — Does the web server respond with valid status codes?
  6. TLS Certificate — Is the SSL certificate valid and not expired?
  7. Connection Timing — How long does each phase of the connection take?
Terminal window
# Run with default target (example.com)
bash scripts/diagnostics/connectivity.sh
# Run against a specific domain
bash scripts/diagnostics/connectivity.sh google.com
# Protocol prefix is stripped automatically
bash scripts/diagnostics/connectivity.sh https://mysite.com
# Or via Makefile
make diagnose-connectivity TARGET=example.com
make diagnose-connectivity TARGET=google.com

The diagnostic is non-interactive and produces output directly to the terminal. Protocol prefixes (http:// or https://) are automatically stripped from the target.

Detects local network configuration using platform-specific methods.

CheckSeverityMeaning
Local IP detectedPASSYour machine has a network interface with an IP address
Local IP not detectedWARNCould not determine local IP — may indicate no active network interface
Default gateway detectedPASSA default route exists (you have internet access path)
Default gateway not detectedWARNNo default gateway found — you may not have internet access

The local IP detection is platform-aware: it uses ifconfig on macOS (Darwin) and ip on Linux. This is because iproute2mac’s ip command behaves differently on macOS.

Checks if the target domain resolves to an IPv4 address using dig +short.

CheckSeverityMeaning
DNS resolvesPASSDomain resolved to an IP address (shown in output)
DNS failsFAILNo A record returned — the domain cannot be reached by name

DNS failure is a hard [FAIL] because all subsequent checks depend on name resolution.

Sends 3 ICMP echo requests (ping) with a 5-second timeout.

CheckSeverityMeaning
Ping succeedsPASSHost responds to ICMP — includes packet stats and RTT
Ping failsWARNHost may block ICMP — this is filtering, not necessarily broken connectivity

ICMP failure is a [WARN], not a [FAIL]. Many hosts and firewalls block ICMP echo requests as a security measure. A failed ping does not mean the host is unreachable — it only means ICMP is filtered.

The ping command is platform-aware: macOS uses ping -c 3 -t 5 (timeout via -t) while Linux uses ping -c 3 -w 5 (timeout via -w).

Tests whether TCP ports 80 (HTTP) and 443 (HTTPS) are open.

CheckSeverityMeaning
Port 80 openPASSHTTP port is reachable
Port 80 closed/filteredWARNHTTP port is not reachable (may be intentional)
Port 443 openPASSHTTPS port is reachable
Port 443 closed/filteredWARNHTTPS port is not reachable
Neither port reachableFAILNo web service is accessible on standard ports

The diagnostic uses nc -z -w 3 when netcat is available, falling back to curl connection tests if nc is not installed.

Sends HTTP and HTTPS HEAD requests and checks the status code.

CheckSeverityMeaning
2xx or 3xx responsePASSServer responded successfully (or with redirect)
4xx responseWARNClient error (e.g., 403 Forbidden, 404 Not Found)
000 (no response)WARNConnection failed — no HTTP response received
Other codesWARNUnexpected status code

The diagnostic checks both HTTP and HTTPS independently, with a 5-second connect timeout and 10-second max time.

Inspects the SSL/TLS certificate using curl -vI.

CheckSeverityMeaning
Certificate foundPASSTLS certificate exists, expiry date shown
Certificate valid for 30+ daysPASSCertificate is not expiring soon
Certificate expires in < 30 daysWARNCertificate is expiring soon — renew it
Certificate expiredFAILCertificate has expired — browsers will reject the connection
Certificate not verifiableFAILCould not verify the TLS certificate

When openssl is available, the diagnostic calculates the exact number of days until certificate expiry. The output also shows the certificate subject and issuer for identification.

Measures the time spent in each phase of an HTTPS connection.

MetricWhat It Measures
DNSTime to resolve the domain name
ConnectTime to establish TCP connection
TLSTime to complete TLS handshake
First byteTime to receive the first byte of response (TTFB)
TotalTotal request time from start to finish
CheckSeverityMeaning
Timing collectedPASSAll timing phases measured successfully
Total > 5 secondsWARNConnection is slow — investigate which phase is the bottleneck
Timing not availableWARNCould not connect to measure timing

The report ends with a summary line showing total counts:

[WARN] 10 passed, 0 failed, 3 warnings (13 checks)
  • If any check failed: the summary line is marked [FAIL]
  • If no failures but warnings exist: the summary line is marked [WARN]
  • If all checks passed: the summary line is marked [PASS]

Full connectivity is confirmed at every layer: DNS resolves, ICMP reaches the host, TCP ports are open, HTTP/HTTPS respond, TLS certificate is valid, and timing is acceptable.

Common and often expected. Typical warnings include:

  • ICMP ping failed — Host blocks ICMP. This is normal for many web servers and cloud providers.
  • Port 80 closed — HTTPS-only site that does not listen on port 80.
  • HTTP 4xx response — Server returns a client error for the root URL (e.g., API servers that require authentication).
  • Total > 5 seconds — Slow connection, possibly due to geographic distance or server load.

Indicates a real connectivity problem:

  • DNS resolution failed — Domain cannot be resolved. Check if the domain exists and DNS is properly configured.
  • Neither port 80 nor 443 reachable — No web service is running, or a firewall is blocking all traffic.
  • Certificate expired — TLS certificate needs renewal.
  • Certificate not verifiable — Certificate may be self-signed, chain may be incomplete, or the wrong certificate is served.
IssueLikely CauseFix
DNS resolution FAILDomain does not exist or DNS misconfiguredVerify domain and DNS records with make diagnose-dns TARGET=<domain>
ICMP WARNHost blocks pingNot a problem — proceed to check TCP ports
Both ports closedFirewall blocking, service not runningCheck firewall rules, verify web server is running
HTTP 000Connection timeoutCheck network path, DNS, and server availability
Certificate expiredAuto-renewal failedRenew certificate (e.g., certbot renew for Let’s Encrypt)
Slow timing (> 5s)Geographic distance, server overloadCheck which phase is slow (DNS, TLS, etc.) and address that layer

The diagnostic requires the following tools:

ToolRequiredInstall
curlYesapt install curl (Debian) / dnf install curl (RHEL) / Pre-installed on macOS
digYesapt install dnsutils (Debian) / dnf install bind-utils (RHEL) / brew install bind (macOS)
ncOptionalUsed for TCP port checks; falls back to curl if not available
opensslOptionalUsed for certificate expiry calculation; report still works without it
pingOptionalPre-installed on all platforms; used for ICMP reachability