Diagnosing Intermittent Timeouts That Disappear When You Check

Diagnosing Intermittent Timeouts That Disappear When You Check

Intermittent timeouts are among the most frustrating website problems to deal with: the uptime monitoring alert fires, someone opens the site in a browser, and the page loads in 400 milliseconds. Diagnosing intermittent timeouts that vanish by the time anyone looks takes a different method than chasing a hard outage, because the evidence is usually gone within minutes. This article explains why these failures hide from manual checks, how to find the layer that is actually timing out, and which causes come up most often.

Why the Problem Is Gone When You Look

A manual check in a browser is a poor comparison with an automated uptime check. The browser already has DNS cached and reuses an open keep-alive connection, and it may get the page from a CDN edge that is already holding it. An HTTP monitor usually opens a new connection on every check. That means a fresh DNS lookup, a fresh TCP handshake and a fresh TLS negotiation each time.

Timing is the other half of the problem. A 45-second stall caused by a database lock is over long before the alert email gets read and someone opens a laptop. By the time a person checks, 3-5 minutes have usually passed, and the problem has already cleared.

A Pattern Practitioners Recognize

Take a typical online store running WooCommerce on a single VPS. It gets 2-4 timeout alerts a week, and each one clears on the next one-minute check. The team decides it is “monitor noise” and stops paying attention to the alerts.

Weeks later, a customer reports that checkout hung late at night. Someone finally exports the alert timestamps into a spreadsheet. Every failure falls between 02:00 and 02:20 server time. That is when a nightly mysqldump job runs without the –single-transaction flag, so it locks the tables the order pages read from. The monitor was never wrong. It caught a real problem a few times each night and reported it accurately.

Myth: If You Can’t Reproduce It, It’s a False Positive

This is the most expensive misconception in the area. Real false positives do exist, but they look different. They usually come from a single checking location, return a recognizable status such as a 403 from a WAF, or line up with a known network incident at the monitoring provider.

A timeout that repeats at similar times, on the same URLs, or across several checking locations is almost always a real problem. Users are hitting it too. Most of them just don’t report it.

Step-by-Step Approach to Diagnosing Intermittent Timeouts

Step 1 – Build a timeline. Export every failed check from the last 30 days, then sort the failures by hour of the day, minute of the hour and day of the week. Failures that cluster at :00 or :30 usually point to cron jobs. Clusters in the middle of the night suggest backups or log rotation. If failures follow deployments within 10-20 minutes, suspect cache warm-up or memory leaks.

Step 2 – Find the phase that stalls. From a machine outside your own network, run curl in a loop every 10 seconds for a few hours:

curl -o /dev/null -s -w “dns:%{time_namelookup} connect:%{time_connect} tls:%{time_appconnect} ttfb:%{time_starttransfer} total:%{time_total}n” https://example.com/

Each kind of stall points somewhere different. A DNS delay of almost exactly 5 seconds suggests a resolver problem, because 5 seconds is the default timeout in glibc’s resolv.conf. Connect times of about 1, 3 or 7 seconds match Linux SYN retransmission backoff, which means SYN packets are being dropped. Common reasons are a full listen backlog or an exhausted conntrack table. A long time-to-first-byte means the application itself is slow.

Step 3 – Check whether the request reached the server. Add $request_time and $upstream_response_time to your Nginx log_format, then search the logs around each failure timestamp. If the request is missing, the problem is in front of the application: the load balancer, a firewall, DNS or the kernel. If the request was logged with an upstream time of 60.001 seconds and a 504 status, the backend hit Nginx’s default proxy_read_timeout.

Step 4 – Split the data by node and by region. If one of four instances behind a load balancer is unhealthy, roughly 25% of new connections fail, and from the outside that looks completely random. The same approach applies to CDN edges and geographic regions. The guide on detecting partial outages that only affect some users covers this in more detail.

The Usual Suspects

An experienced SRE checks worker pool exhaustion first. When PHP-FPM reaches pm.max_children, new requests wait in a queue until a worker is free. The FPM log says so directly: “server reached pm.max_children setting.” A few slow requests can fill every worker for 30 seconds, and then the pool recovers on its own.

Database contention comes next. Lock waits, long-running reports and missing indexes on tables that keep growing all cause stalls that come and go. These often show up in the slow query log weeks before they cause a full outage, as explained in how to spot slow database queries before they take you down.

Infrastructure causes are worth checking too. AWS T2 or T3 instances in standard credit mode get throttled to their baseline CPU once their credits run out. On a t3.small, the baseline is 20% of a vCPU. JVM applications can pause for several seconds during full garbage collection. Serverless functions on AWS Lambda or Google Cloud Run add cold-start latency after periods of no traffic, so a low-traffic site can time out on the first request after a quiet hour.

Common Mistakes When Chasing Ghost Timeouts

The most common mistake is raising the monitor’s timeout from 10 to 60 seconds to make the alerts stop. The alerts do stop, but the problem stays. Real visitors leave long before 60 seconds, so the change only hides what they experience. Choosing timeout and retry settings for HTTP uptime checks explains how to set these values without hiding real failures.

The second mistake is restarting services as the first response. A restart clears the stuck workers, the full connection pool and the lock queue, which is exactly the evidence you need. A seasoned engineer collects evidence before restarting: the output of ss -s, a thread dump, SHOW PROCESSLIST and the FPM status page. Collecting all of that takes about 60 seconds.

The third mistake is relying on averages. A median response time of 300 ms can coexist with a 99th percentile of 12 seconds. Averages hide exactly the slow outliers that become timeouts.

There are a few exceptions to this process. Sites on shared hosting usually have no access to server logs, so the practical step is to send the host exact failure timestamps in UTC and ask for their logs from those windows. Sites behind Cloudflare or other bot protection may have their monitoring requests challenged or dropped. If failures only ever come from one checking location, look at the firewall rules before looking at the application.

FAQ

How many failed checks should trigger an alert?
With one-minute checks, a common setup is to alert after two consecutive failures, or after one failure followed by a failed retry 20-30 seconds later. This filters out short network blips but still catches anything that lasts longer than about two minutes. Keep logging single failures anyway, because they are the raw data for finding patterns.

Can the uptime monitor itself cause the timeouts?
That is very unlikely, since one request per minute adds negligible load. The exception is rate limiting or WAF rules that treat repeated requests from the same IP addresses as bot traffic and throttle them.

What timeout value should an HTTP uptime check use?
For most pages, 10-15 seconds is a sensible limit. Heavy endpoints such as reports or search can justify 20-30 seconds. Anything longer mostly hides problems your users are already experiencing.

Summary

Intermittent timeouts that disappear when you check are rarely random. They follow a schedule, affect one node, or stall at one specific phase of the connection. Collect the failure timestamps, measure each phase with curl, confirm whether the request ever reached the server, and gather evidence before restarting anything. The most useful habit is to treat every single failed check as a data point to record, even when it is not yet something to react to.