One failed call, six layers#
"The payments call failed" is what the service's error rate says. The same failed call can come from six places, and each leaves a different first error:
- Name resolution. The client never got an address. The resolver answered that the name does not exist, could not answer, or did not answer in time.
- TCP connection. The client had an address and could not open a connection to it: nothing listened, a firewall dropped the packets, there was no route, or the client's own ports or a NAT gateway's ran out.
- TLS handshake. The connection opened and the two sides could not agree: a certificate expired, did not cover the name, chained to a root the client lacks, or the two sides share no protocol version.
- Connection pool and client. The client waited for a connection or a thread of its own and gave up before it sent anything.
- The dependency's server. The request arrived and the dependency refused it, throttled it or answered slowly: a database out of connection slots, a cache out of memory, a provider rate limit.
- Asynchronous work. Nothing failed on the call itself. A message was published and its consumer did not process it, so the failure shows up as a backlog or an age.
The layer decides who acts next and which dashboard is worth opening. A resolver failure is rarely fixed in the dependency. A refused TLS handshake is rarely load. A pool timeout can sit entirely inside your own service while the database is idle. Opening the dependency's CPU graph first costs the minutes the first error would have saved.
Where each layer shows up in the error#
Most runtimes keep the system's error code in the message. Node.js reports a lookup that found no such name as ENOTFOUND, which covers EAI_NONAME and EAI_NODATA, and keeps ECONNREFUSED, ECONNRESET and ETIMEDOUT from the socket layer. glibc's getaddrinfo returns EAI_AGAIN for a temporary resolver failure. OpenSSL reports a failed certificate check with a verify error, such as certificate has expired or unable to get local issuer certificate. Node.js common system errors · getaddrinfo(3) · connect(2) errors · OpenSSL verify errors
| First error | Layer | Separate it from its neighbor |
|---|---|---|
Name not found, NXDOMAIN | Resolution | Ask the authoritative server |
| Temporary resolver failure | Resolution | Repeat the lookup and read the resolver |
| Connection refused | TCP | Refused, timed out or unreachable |
| Connect timeout | TCP | Firewall, route or listen queue |
| Connection reset on a reused connection | TCP | Idle timeout on the path |
| Cannot assign requested address | Client host | Ephemeral ports |
| Certificate expired or not yet valid | TLS | Which certificate, which clock |
| Unable to get local issuer certificate | TLS | Missing intermediate or missing root |
| Handshake failure or protocol version alert | TLS | Protocol floor or cipher |
| Timed out waiting for a pooled connection | Pool | Pool or database |
| Too many clients, max clients reached | Server | Who holds the connections |
| 429, throttling, slow down | Server | Your quota or their outage |
| Backlog or age keeps growing | Async | Consumers absent, failing or slow |
A wrapped exception can hide the layer. A Java SQLException from a pool, a Python requests.exceptions.ConnectionError or a gRPC UNAVAILABLE status can each wrap any of the first three layers. Read the innermost cause in the stack trace, or the first log line from the client library, before you read the outer message.
Walk the layers in order from one instance#
When the error does not name its layer, take one instance that fails and walk the call outward, one layer per command. Each command reads state and changes nothing on the dependency. Run them inside the failing container or host, since a laptop resolves names and routes packets differently. getent(1) · openssl-s_client · curl write-out variables
# 1. Resolution, through the same resolver library the service uses
getent ahosts payments.example.com
# 2. TCP, to the address getent printed
nc -vz -w 5 payments.example.com 443
# 3. TLS, with the name the client sends
openssl s_client -connect payments.example.com:443 \
-servername payments.example.com -verify_return_error </dev/null
# 4. The whole request, with the time spent in each phase
curl -sS -o /dev/null https://payments.example.com/health -w \
'dns %{time_namelookup}s connect %{time_connect}s tls %{time_appconnect}s first byte %{time_starttransfer}s status %{http_code}\n'
The first command that fails names the layer. getent reads /etc/nsswitch.conf and /etc/hosts the way the C library does, so it can disagree with dig, which asks a DNS server directly. Use both when resolution is in doubt. curl's timings are cumulative from the start of the request: time_connect minus time_namelookup is the TCP connect, and time_appconnect minus time_connect is the TLS handshake.
If all four succeed from the failing instance, the network path, the certificate and the dependency's front door work right now. Look at the client's pool and timeouts, and at the dependency's view of the requests. Client-side or server-side latency
A worked sample: two payments incidents with the same alert#
This sample is illustrative. A fictional service checkout calls payments.example.com over HTTPS. At 09:40 UTC its alert fires: 18% of payment calls fail. Both incidents below start with the same alert and the same graph.
Incident one. The client log's innermost error is a certificate verification failure. The walk from one checkout container:
| Layer | Result at 09:44 |
|---|---|
getent ahosts | 203.0.113.20, 203.0.113.21 |
nc -vz to each | both connect |
openssl s_client to .20 | verify return code 0 |
openssl s_client to .21 | verify return code 10, certificate has expired |
One of the two addresses behind the name serves a certificate whose notAfter passed at 09:38. Roughly a fifth of new connections land there; the rest succeed. The payments provider's servers are up and fast. The decision is to report the expired certificate on .21 to the team that owns it, with the notAfter and the address, and leave checkout alone: no retry setting or rollback changes which certificate a server presents. Which certificate in the chain expired
Incident two. The innermost error is a pool acquisition timeout after 5 seconds. The walk:
| Layer | Result at 09:44 |
|---|---|
getent ahosts | 203.0.113.20, 203.0.113.21 |
nc -vz to each | both connect |
openssl s_client to each | verify return code 0 |
curl -w | dns 0.002s, connect 0.004s, tls 0.019s, first byte 0.061s |
Every layer works from the failing container, and the payments API answers in 61 ms. The pool's own metrics show all 20 connections checked out and 140 requests waiting. A code path added the day before holds a pooled HTTP connection while it reads a large response body slowly. The dependency is healthy; the bottleneck is checkout's pool. The decision is the opposite of incident one: the fix is in checkout, and the payments team has nothing to do. Pool exhausted by the app or waiting on the server
Where to observe each dependency without changing it#
The walk tests the path from one instance. The dependency's own view comes next, and most dependencies expose it read-only:
- DNS. Query the configured resolver and the authoritative server separately with
dig, and read the resolver's logs where they exist. DNS answers - PostgreSQL.
pg_stat_activitylists every session with its client address, application name and state. Who holds the connections - Redis.
INFO clients,INFO memoryandINFO statsread counters without touching keys. Max clients or timeouts - Queues. Queue depth, the age of the oldest message and consumer offsets come from the broker's metrics or describe commands; receiving a message to look at it is a change. SQS backlog · Kafka lag
- Provider APIs. Response headers carry the rate limit and the request ID; AWS records throttled API calls in CloudTrail. AWS throttling or quota
Limits of reading the first error#
The first error comes from the client, and a client can report the wrong layer. Some libraries turn every failure into a generic timeout, retry before logging, or log only the last of several attempts. When the message is generic, the walk above is the evidence, not the message.
One instance is one path. A failure that hits a fraction of calls can come from one of several addresses, one zone, or one host's resolver, so walk a second instance and every address the name returns before you generalize.
A dependency can fail at more than one layer at once. A database that has run out of connection slots still accepts TCP connections, so nc succeeds and a real client session fails. Test the layer the client actually uses. Timeouts only from new tasks · Bad release or unhealthy dependency?
The guides in this collection#
Each guide starts from one error or metric, names the nearby causes it can mean, and gives the read-only check that separates them.
Name resolution:
- DNS lookup failed: NXDOMAIN, SERVFAIL, NODATA or no answer?
- Temporary failure in name resolution or name not known?
- Why one external lookup from a Kubernetes pod sends many queries
- New DNS record still returns NXDOMAIN from some clients
- Clients still use the old address after a database failover
- DNS lookups time out under load on EC2: the resolver packet limit
- Route 53 private hosted zone names do not resolve from a VPC
- Same hostname, different answer inside and outside the network
- SERVFAIL from a validating resolver: is DNSSEC broken?
- Only large DNS answers fail: truncation and blocked TCP port 53
- Connect timeouts when a name has IPv6 addresses the host cannot reach
TLS:
- Which certificate expired when a dependency call fails?
- Unable to get local issuer certificate: server chain or client trust?
- TLS hostname mismatch calling a dependency: which name is wrong?
- Why does my client get the wrong certificate from a shared endpoint?
- TLS works on the host but fails inside the container
- TLS protocol version or handshake failure alert from a dependency
- Mutual TLS rejected: whose certificate failed, and who logs it?
- Database TLS failing after an Amazon RDS certificate authority change
- Certificate is not yet valid: client clock or a brand-new certificate?
Connections and pools:
- Connection refused or timed out: what each error tells you
- Connection resets on idle pooled connections after a quiet period
- Occasional socket hang up on reused HTTP keep-alive connections
- Pool acquire timeout: a busy pool or a struggling database?
- Who is holding all the PostgreSQL connections right now?
- Connections fail through a NAT gateway that has run out of ports
- Cannot assign requested address when calling a dependency
- Slow connects to a dependency that looks idle: a full listen queue
- Internal calls failing through a proxy from environment variables
- Dependency slow for the client but fast on the server
Queues:
- Why are SQS messages piling up without being processed?
- Why does my SQS consumer process the same message twice?
- Why is my SQS dead-letter queue filling up?
- Is Kafka consumer lag growing because consumers stalled or are slow?
- Why does my Kafka consumer keep leaving the group and rebalancing?
- Why do RabbitMQ publishers hang while consumers keep working?
- Why is my Pub/Sub backlog growing and its oldest message aging?
Caches and provider APIs:
- Redis max clients reached, or timeouts from a slow server?
- Why does Redis refuse writes with an OOM error?
- Redis READONLY errors after a failover: which node is the client on?
- Third-party API returns 429 or 503: your quota or their outage?
- AWS API throttling or a service quota: which limit did you hit?
- S3 503 Slow Down errors: a hot prefix or a regional problem?
When the failure began with a deploy, sort the release from the dependency first: Bad release or unhealthy dependency?
Questions#
How do I tell whether the dependency or my service is failing?
Walk the call from one failing instance: resolve the name, open a TCP connection, complete the TLS handshake and send one request with timing. If every step succeeds and the request is fast, the dependency's front door works and the failure is more likely in your service's pool, threads or timeouts. If a step fails, that step's layer is where to look.
Why does dig find the name when my service cannot?
dig sends a DNS query to a server directly. Your service resolves through the C library or its runtime, which reads /etc/hosts, the search list and nsswitch.conf and may cache answers. Compare with getent ahosts, which uses the same library path as most services.
Is a successful nc test enough to rule out the network?
It shows that a TCP connection opens from that instance to that address now. TLS, authentication, the dependency's connection limit and other addresses behind the same name can still fail, so continue to the TLS and request steps.