ICMP Ping Success vs. Port 443 Reachability

Easy · Software Engineering Fundamentals · Software Engineer · Onsite

Prompt

Suppose running ping api.payments.example from your workstation returns normal echo replies with 0% packet loss. Does that result guarantee that port 443 on api.payments.example is reachable? Justify your answer, and walk through the concrete steps and command-line tools you would run from your workstation to verify connectivity to port 443.

State any assumptions you would clarify with the interviewer first—such as whether middleboxes (stateful firewalls, cloud security policies, NAT gateways, or reverse proxies) sit on the network path, whether "reachable" refers strictly to completing a transport-layer socket handshake or completing a valid HTTPS exchange, and whether you only care about access from your current client network or across the public internet.

Scope & Expectations

  • Contrast the network-layer diagnostic protocol behind ping with the transport- and application-layer protocols used on port 443, noting which component on the host answers each one.
  • Identify realistic network and host scenarios in which ping replies succeed even though traffic to port 443 fails.
  • Demonstrate direct client-side command-line probes for TCP and HTTPS on port 443, explaining how to distinguish open, connection-refused, and timeout results.
  • Describe a systematic fault-isolation workflow to pinpoint where packets stop when port 443 cannot be reached.

Step-by-step walkthrough

  1. Direct answer: ping and port 443 use different protocols

    No — a successful ping does not mean port 443 is reachable. All a ping proves is that an ICMP (Internet Control Message Protocol — a network-layer diagnostic protocol used for status and error messages) Echo Request reached some device at that IP address and an Echo Reply made it back to your machine.

    Port 443 belongs to transport-layer protocols that ping never touches:

    Tool / Traffic     Layer & Protocol                         Port concept?   Who answers on the server?
    -----------------  ---------------------------------------  --------------  ------------------------------------------
    ping (IPv4)        Layer 3: ICMP (IP protocol 1)            No ports        OS kernel network stack (Echo 8 -> Reply 0)
    ping (IPv6)        Layer 3: ICMPv6 (Next Header 58)         No ports        OS kernel network stack (Echo 128 -> 129)
    HTTPS (HTTP/1.1,2) Layer 4: TCP (IP protocol 6)             Port 443        User-space web server or proxy (e.g. Nginx)
    HTTPS (HTTP/3)     Layer 4: QUIC over UDP (IP protocol 17)  Port 443        User-space QUIC/HTTP/3 server or proxy
    

    Because TCP (Transmission Control Protocol — a connection-oriented transport protocol that numbers application endpoints with ports 0–65535) and UDP (User Datagram Protocol — a connectionless transport protocol that also uses ports 0–65535) are separate protocols from ICMP:

    1. Every packet filter, router, and cloud security policy on the route evaluates ICMP and TCP port 443 under separate rule sets.
    2. The operating system kernel answers ping automatically even if the web server process has crashed or was never installed.

    To know whether port 443 on api.payments.example is usable, you must probe port 443 itself from the client network you care about.

  2. Checklist: what HTTPS needs vs what ping actually tests

    Align with the interviewer on whether "reachable" means "a TCP socket handshake completes on port 443" or "an HTTPS client completes a verified request". Putting every requirement side by side shows why ping cannot prove either one:

    Requirement                                                  Tested by ping?   TCP connect :443   Full HTTPS request
    -----------------------------------------------------------  ----------------  -----------------  ------------------
    1. DNS resolves hostname to the intended IP (A or AAAA)      Yes*              Yes*               Yes
    2. IP routing exists from client to server and back          Yes               Yes                Yes
    3. Firewalls / security groups allow ICMP Echo               Yes               No (not needed!)   No (not needed!)
    4. Firewalls / security groups allow TCP to port 443         No                Yes                Yes
    5. A process is actively listening on port 443 on that IP    No                Yes                Yes
    6. Return path allows TCP replies back to client             No                Yes                Yes
    7. TLS handshake succeeds (packet size, TLS version/cipher)  No                No                 Yes
    8. Server certificate is valid, unexpired, and matches host  No                No                 Yes
    9. Web application responds healthy (e.g. HTTP 200)          No                No                 Yes
    
    * Only if you ran the command with the hostname rather than a raw IP address.
    

    ping checks items 1–3, and item 3 is not even required for HTTPS. Items 4–9 remain completely untested.

  3. Five real-world reasons ping succeeds while port 443 fails

    In production networks, ping and port 443 routinely give opposite answers for five concrete reasons:

    • Protocol- and port-specific firewall rules: a cloud security group (virtual instance firewall) evaluates each rule per protocol and port range:

    text Security Group A: Allow TCP 443 from 0.0.0.0/0 -> ping FAILS, HTTPS WORKS from anywhere Security Group B: Allow ICMP Echo from 0.0.0.0/0 Allow TCP 443 from 10.0.0.0/16 -> ping WORKS from anywhere, port 443 WORKS only inside 10.0.0.0/16

    • No process listening on the public interface: Nginx or Envoy may be stopped, listening on port 8443 instead of 443, or bound only to loopback (127.0.0.1:443) instead of 0.0.0.0:443. The OS kernel still answers ping, while TCP port 443 immediately rejects connections.
    • A middlebox answers the ping: behind DNAT (Destination Network Address Translation — a router or firewall feature that rewrites a public IP/port to a private backend server) or an edge load balancer, the public IP belongs to the front box. Its Echo Reply only proves the front box is alive, not that port 443 is forwarded or that the backend pool is up.
    • IPv4 vs IPv6 path split: if DNS publishes both an A record (IPv4) and an AAAA record (IPv6), ping may test IPv4 while your browser connects over IPv6 (or vice versa), hitting different routes and firewall policies.
    • MTU black holes break TLS after ping and TCP succeed: MTU (Maximum Transmission Unit) is the largest IP packet size in bytes a link can forward without fragmentation (1500 bytes on standard Ethernet, often 1400–1420 bytes inside VPN or overlay tunnels). A default Linux or macOS ping sends a 56-byte payload (56 + 8 ICMP header + 20 IPv4 header = 84 bytes total), and TCP SYN packets are only 40–60 bytes, so both slip easily through a 1400-byte tunnel. During TLS (Transport Layer Security — the cryptographic protocol that encrypts HTTPS), the server sends its multi-kilobyte certificate chain in full 1500-byte packets with the "Don't Fragment" (DF) flag set. If a firewall drops the tunnel's ICMP "Fragmentation Needed" error, the TLS handshake stalls! You can test path MTU directly by setting DF and varying payload size: ping -M do -s 1472 host on Linux (ping -D -s 1472 host on macOS) sends 1472 + 8 + 20 = 1500 bytes; if -s 1372 (1400 bytes) succeeds while -s 1373 (1401 bytes) fails, the path MTU is 1400 bytes.
  4. Test port 443 directly from your workstation

    Run a tool that opens a real TCP connection (and optionally a TLS/HTTPS session) to api.payments.example:443 from the exact client workstation or network in question:

    # 1. Pure TCP port reachability (Layer 4 only):
    nc -vz -w 3 api.payments.example 443                        # netcat: 3-second timeout, connect and close
    Test-NetConnection api.payments.example -Port 443           # Windows PowerShell: check "TcpTestSucceeded : True"
    nmap -Pn -p 443 api.payments.example                        # reports open / closed / filtered (-Pn skips ping check)
    
    # 2. Full HTTPS check (DNS -> TCP -> TLS -> HTTP):
    curl -v --connect-timeout 5 https://api.payments.example/   # prints resolved IP, TCP connect, TLS version, HTTP status
    
    # 3. Deep TLS and certificate inspection:
    openssl s_client -connect api.payments.example:443 -servername api.payments.example
    

    Always pass -servername to openssl s_client so it sends SNI (Server Name Indication — a TLS handshake field telling a server that hosts multiple domains which hostname's certificate to present). Also remember that a test speaks only for the network where you ran it: to verify "reachable from anywhere on the public internet," run checks from external vantage points (such as cloud VMs in multiple regions or synthetic probes), and test UDP port 443 separately (curl --http3) if HTTP/3 matters.

  5. Interpret the three TCP outcomes: open, refused, and timed out

    Opening a TCP connection starts with a three-way handshake: the client sends a SYN (synchronize) packet, an open server answers SYN-ACK (synchronize-acknowledge), and the client replies ACK (acknowledge). What comes back after your SYN immediately narrows down the root cause:

    Client sends TCP SYN -> port 443:
    
      Case 1 (OPEN):      Client ---SYN---> Server
                          Client <--SYN-ACK- Server   => Port 443 is open and accepting connections.
    
      Case 2 (CLOSED):    Client ---SYN---> Server
                          Client <--RST----- Server   => "Connection refused": packets reached the host,
                                                         but no process is listening on port 443 (or a
                                                         firewall rule explicitly rejected with TCP reset).
    
      Case 3 (FILTERED):  Client ---SYN---> [X]       => "Connection timed out": a firewall silently dropped
                          (silence until timeout)        the SYN (or dropped the returning SYN-ACK), or no
                                                         valid route exists.
    

    Notice the diagnostic gold in Case 2 vs Case 3: Connection refused arrives in milliseconds and proves network routing is working; Connection timed out means packets are disappearing in transit.

    Always pass an explicit timeout (-w 3 or --connect-timeout 5). Without one, the OS retries a dropped SYN with exponential backoff: on Linux with the classic default 1 s initial timeout and net.ipv4.tcp_syn_retries = 6, retries fire after 1 + 2 + 4 + 8 + 16 + 32 = 63 s and the final wait adds 64 s, blocking your terminal or script for roughly 127 s (over two minutes; macOS waits ~75 s).

  6. Pinpoint where dropped packets stop along the path

    When port 443 times out from your laptop, isolate the faulty hop systematically:

    1. Compare vantage points: test on the server itself (curl -vk https://127.0.0.1/), from a sibling VM in the same subnet, from your laptop, and from an independent network (such as a phone hotspot). Working on 127.0.0.1 but failing from the same subnet points to a wrong bind address or host firewall; working from the subnet but timing out from outside points to a perimeter firewall, security group, or return-path bug.
    2. Verify the listening socket on the server: run ss -ltnp | grep ':443' on Linux (netstat -an | grep 443 elsewhere). Confirm a process is bound to 0.0.0.0:443 or [::]:443 rather than only 127.0.0.1:443.
    3. Capture packets on the server while attempting to connect: run tcpdump -ni any 'tcp port 443 and host <client-ip>':
      • No SYN arrives: an upstream security group, perimeter firewall, or client egress filter dropped it before reaching the host.
      • SYN arrives, nothing leaves: the server's own host firewall (iptables / nftables / ufw) dropped it (tcpdump sees incoming frames before Linux netfilter rules run).
      • SYN arrives, SYN-ACK leaves, client still times out: the return path is broken (for example, a stateless network ACL — a packet filter that checks inbound and outbound rules independently without remembering active connections — is blocking outbound traffic to the client's high-numbered ephemeral source port, or asymmetric routing is bypassing a stateful firewall).
    4. Run a TCP traceroute on port 443: use traceroute -T -p 443 host or mtr -T -P 443 host so the TTL-limited probe packets are real TCP SYNs to port 443 rather than ICMP or high-port UDP probes that firewalls treat differently.
  7. Automate a layered check in Python

    Writing the check in Python makes each layer (DNS -> TCP -> verified TLS) explicit and reports the exact layer that failed instead of lumping every failure into "site down":

    import socket
    import ssl
    
    
    def check_https_port(host: str, port: int = 443, timeout: float = 3.0) -> str:
        """Test DNS, TCP connect, and verified TLS on host:port, reporting which layer failed."""
        # Layer 1: resolve hostname to stream (TCP) socket addresses.
        try:
            addr_infos = socket.getaddrinfo(host, port, type=socket.SOCK_STREAM)
        except socket.gaierror as err:
            return f"DNS failed for {host}: {err}"
    
        ip = addr_infos[0][4][0]
    
        # Layer 2: attempt TCP three-way handshake with an explicit short timeout.
        try:
            raw_sock = socket.create_connection((ip, port), timeout=timeout)
        except ConnectionRefusedError:
            return f"TCP refused by {ip}:{port} (RST received: host reachable, nothing listening)"
        except (TimeoutError, socket.timeout):
            return f"TCP timed out to {ip}:{port} (SYN or SYN-ACK dropped by firewall or routing)"
        except OSError as err:
            return f"TCP error to {ip}:{port}: {err}"
    
        # Layer 3: run TLS handshake with SNI (server_hostname) and full certificate verification.
        tls_context = ssl.create_default_context()
        with raw_sock:
            try:
                with tls_context.wrap_socket(raw_sock, server_hostname=host) as tls_sock:
                    tls_version = tls_sock.version()
            except ssl.SSLCertVerificationError as err:
                return f"TCP open on {ip}:{port}, but certificate verification failed: {err.verify_message}"
            except (ssl.SSLError, OSError) as err:
                return f"TCP open on {ip}:{port}, but TLS handshake failed: {err}"
    
        return f"OK: {ip}:{port} accepted TCP and completed a verified {tls_version} handshake"
    

    Calling check_https_port("localhost", 1) fails in milliseconds with "TCP refused...", calling it against a firewalled port fails cleanly after 3.0 s with "TCP timed out...", and a healthy HTTPS server returns "OK: ... TLSv1.3 handshake". In production, iterate over every address in addr_infos so a broken IPv6 or secondary IPv4 record cannot hide behind one healthy address.

Intuition & how it works

Think of a server's IP address as a large office building, and port 443 as Room 443 inside where the HTTPS reception desk operates. Running ping is like pressing the building's street intercom and hearing the lobby guard buzz back: it proves the street address exists and the guard is allowed to answer the intercom, but it tells you nothing about whether building security lets visitors walk up to Room 443, whether anyone is sitting at the desk inside Room 443, or whether their ID badge is valid.

Why does the naive assumption ("ping works, so the website port must be reachable") fail? First, ping uses ICMP (Internet Control Message Protocol — a network-layer diagnostic protocol that has no port numbers at all), whereas HTTPS runs over TCP (Transmission Control Protocol — a connection-oriented transport protocol using ports 0–65535) on port 443, or over UDP (User Datagram Protocol) port 443 for HTTP/3, and firewalls filter each protocol and port independently. Second, the operating system kernel answers ping automatically in the background even when the web server process has crashed. Third, a front-end load balancer or NAT gateway may answer ping at the public IP while dropping or failing to forward port 443 traffic, or a TLS (Transport Layer Security — the encryption layer inside HTTPS) handshake may stall on oversized packets even after small ping packets succeed.

Trace 4 probes from your workstation (198.51.100.42) to api.payments.example (203.0.113.85) to see how completely independent the outcomes are:

  1. Ping succeeds (12 ms): your workstation sends an 84-byte ICMP Echo Request (56 data + 8 ICMP + 20 IPv4 bytes); the firewall permits ICMP and the server's OS kernel replies with an Echo Reply.
  2. Port 443 filtered (3.0 s timeout): your workstation sends a TCP SYN (connection-start) packet to 203.0.113.85:443, a cloud security policy silently drops TCP 443 from external IPs, and nc -vz -w 3 fails with Connection timed out.
  3. Port 443 closed (12 ms refused): you open the firewall rule, send another TCP SYN to :443, the packet reaches the server while Nginx is stopped, and the OS kernel immediately answers with a TCP RST (reset) packet — nc fails with Connection refused.
  4. Port 443 healthy (35 ms HTTP 200): you start Nginx on 0.0.0.0:443; now SYN receives SYN-ACK, the client finishes TCP + TLS certificate verification, and curl -v https://api.payments.example/ receives HTTP/2 200.

Key points

  • Independent protocols and layers: ping tests Layer 3 ICMP Echo (IP protocol 1, no ports), whereas HTTPS tests Layer 4 TCP port 443 (IP protocol 6) or QUIC over UDP port 443 (IP protocol 17) plus Layer 7 TLS and HTTP.
  • Narrow meaning of ping: a successful ping proves bidirectional IP routing for small ICMP packets and an active network stack at that IP—not firewall permission for TCP 443, a listening process, backend health behind NAT/load balancers, or valid TLS certificates.
  • Direct port and service tools: use nc -vz -w 3 host 443, Test-NetConnection host -Port 443, or nmap -Pn -p 443 host to test raw TCP reachability; use curl -v --connect-timeout 5 https://host/ and openssl s_client -connect host:443 -servername host to verify TLS and HTTP.
  • Three diagnostic TCP states: SYN-ACK means open; RST (Connection refused) means packets reached the host's IP stack but nothing is listening on port 443; silence (Connection timed out) means a firewall or routing hop silently dropped the SYN or SYN-ACK.
  • Packet-size mismatch (MTU): default ping packets are 84 bytes while TLS certificate flights fill 1500-byte Ethernet frames; if a VPN/tunnel has a 1400-byte MTU (Maximum Transmission Unit — the largest unfragmented IP packet a link carries) and ICMP "Fragmentation Needed" errors are blocked, ping and TCP connect both pass while TLS hangs.
  • Fault localization workflow: compare vantage points (127.0.0.1, same subnet, laptop, phone hotspot), check listening addresses with ss -ltnp, capture on the server with tcpdump to see whether SYN arrives and SYN-ACK leaves, and run traceroute -T -p 443.

Common mistakes

  • Treating ping failure as "server down" or ping success as "HTTPS up": production clouds (such as default AWS security groups) routinely block inbound ICMP Echo while serving HTTPS on TCP 443 normally, and vice versa.
  • Testing from the wrong network vantage point: running curl https://localhost/ on the server bypasses every network firewall and even succeeds when the service mistakenly bound to 127.0.0.1:443 instead of 0.0.0.0:443.
  • Running curl, nc, or telnet without an explicit timeout: OS kernel SYN retries wait ~75–127 s before giving up on a silently dropped port, stalling scripts and CI jobs.
  • Confusing Connection refused with Connection timed out: refused proves routing and firewall transit succeeded and points straight to the server process or bind address; timed out points to packet filtering or routing on the path.
  • Testing only one IP address when DNS returns several: a hostname with both A (IPv4) and AAAA (IPv6) records, or multiple round-robin A records, can succeed on one IP while failing for users who land on another.
  • Passing curl -k (disabling certificate checks) in monitoring scripts: masks expired certificates, wrong hostnames, and missing intermediate certificates that break real browsers and API clients.

Follow-up questions

  • Suppose ICMP echo requests time out, yet HTTPS requests to the same host succeed. What network configurations explain this behavior? Most commonly, a perimeter firewall, cloud security policy, or edge load balancer permits inbound TCP port 443 while dropping or rate-limiting inbound ICMP Echo Requests. Another frequent case occurs inside enterprise networks where workstations reach external sites through an explicit HTTPS forward proxy while direct outbound ICMP from client subnets is blocked at the gateway. Because HTTPS runs over TCP (or QUIC over UDP) and never sends ICMP Echo messages, dropping ping has zero impact on normal HTTPS sessions unless oversized-packet ICMP "Fragmentation Needed" errors are also filtered out.
  • Connecting to TCP port 443 succeeds from a peer VM inside the target subnet, yet hangs until timeout from your workstation. Which culprits are most likely, and how would you isolate the cause? Because the in-subnet VM connected (confirming the server process is listening on 0.0.0.0:443 or its subnet IP) and your workstation timed out rather than receiving Connection refused, packets are silently disappearing between the external network and the subnet. Typical culprits are a security group allowing TCP 443 only from internal CIDR blocks (such as 10.0.0.0/16), an upstream perimeter firewall, a stateless network ACL (a subnet packet filter that evaluates inbound and outbound rules separately, dropping return SYN-ACK packets destined for the workstation's high-numbered ephemeral port such as 54321), or outbound filtering on the workstation's network. Isolate the hop by running tcpdump -ni any 'tcp port 443 and host <workstation-public-ip>' on the server during a test: no incoming SYN points to an upstream or client-egress drop (test via a cellular hotspot to separate the two), whereas SYN arriving and SYN-ACK departing points to a broken return route or stateless outbound ACL.
  • A TCP socket connects on port 443, yet web browsers reject the session with a TLS certificate warning. How would you classify reachability across network layers? At Layer 4 (transport), port 443 is reachable: bidirectional TCP routing works and a TLS listener accepted the connection and transmitted its certificate flight. At Layer 7 (application usability), the service is unhealthy because Certificate Authority (CA) validation—verifying that a trusted issuer signed an unexpired certificate matching the target hostname—failed, causing browsers and strict API clients to abort before sending HTTP requests. Typical causes include an expired leaf certificate, connecting to a raw IP or omitting SNI (Server Name Indication, so the server presents a fallback certificate for another hostname), a missing intermediate certificate in the chain, or an untrusted TLS-inspection proxy; run openssl s_client -connect api.payments.example:443 -servername api.payments.example -showcerts to inspect the exact subject names, chain, and validity dates.
  • How would you design a reliable, automated CI/CD health probe that validates HTTPS availability end to end? Run a multi-layer check from an external runner whose network path matches real clients: resolve every A and AAAA DNS record for the hostname, iterate through all resolved IPs with explicit per-stage timeouts (e.g., 3 s), complete the TCP handshake, validate the full TLS certificate chain (failing or warning early if expiration is within 14 days), and send an HTTPS GET to a dedicated /healthz route expecting HTTP 200 within a defined latency threshold. Emit structured timing metrics and distinct exit/reason codes per layer (DNS, TCP refused, TCP timeout, TLS verification, HTTP status) so alerts pinpoint the broken layer immediately, and retry transient network timeouts 2–3 times with short backoff before failing the pipeline.

Follow-up questions

Similar questions

More Cisco interview questions

All 12 Cisco questions →