HTTP 499: What the client closed request code means and how to fix it
Table of Contents
- Why an unofficial status code deserves your attention
- What the 499 status code means
- How a 499 happens, from click to log line
- How 499 differs from 408, 504 and other 5xx errors
- What causes 499s on web servers
- Humans vs. bots: who's closing the connection
- Reverse proxies, load balancers and gateways
- How to troubleshoot 499s
- What 499s cost you
- Logging and monitoring 499s
- How to prevent 499s
- Updating API clients to handle 499s
- Where 499s show up in the real world
- 499s in microservices architectures
- Common mistakes with 499s
- What to do on Monday
Why an unofficial status code deserves your attention
Have you ever opened an NGINX access log, found a pile of 499s and realized nobody on the team could explain them?
You won't find 499 in RFC 9110, the spec that defines HTTP status codes. It's unofficial. It still shows up in almost any busy access log you open.
Status codes are the server's one-line answer to every request. 2xx means it worked. 3xx means look somewhere else. 4xx means the client did something wrong, and 5xx means the server did.
Most developers know the common ones by heart. The uncommon ones are where debugging time disappears, because nobody recognizes them on sight.
499 is a good example. It looks like an error, it inflates your error rate and it often isn't a bug at all.
The catch?
Sometimes it's the only evidence that your app is too slow for the people (and bots) using it.
What the 499 status code means
499 means the client closed the connection before the server sent a response. NGINX calls it "Client Closed Request."
NGINX invented it. The NGINX source code defines it as NGX_HTTP_CLIENT_CLOSED_REQUEST, and the comment above it says HTTP has no code for this situation, so NGINX made its own.
Fun bit of trivia. A 2003 commit shows it started life as 420 before it moved to 499.
Who uses it
- NGINX itself, plus anything built on it (OpenResty, Kong, the Kubernetes ingress-nginx controller)
- Cloudflare, which logs 499 when a client gives up before Cloudflare responds
- Alibaba Cloud's ALB
- ASP.NET Core, which ships a
Status499ClientClosedRequestconstant
AWS went its own way. The Application Load Balancer logs the same situation as 460.
What it looks like in a log
Here's an illustrative line in NGINX's default combined format.
203.0.113.42 - - [30/Nov/2026:10:14:07 +0100] "GET /api/reports/annual HTTP/1.1" 499 0 "https://example.com/dashboard" "Mozilla/5.0 (Windows NT 10.0; Win64; x64)"
Two things stand out. The status is 499, and the bytes sent is 0.
That zero is the whole story. Nobody ever received a 499. The client was already gone, so the code only exists in your logs.
One gotcha. If the client leaves after NGINX has already sent the response headers, NGINX logs the original status (usually 200) with a short byte count. So 499 only catches disconnects that happen before the response starts.
How a 499 happens, from click to log line
Think of it like ordering at a slow restaurant. You place the order, wait, get bored and walk out. The kitchen is still cooking when the waiter notices your empty chair.
The kitchen didn't fail. You just left first.
Here's the same thing in HTTP terms.
- The user does something (clicks a link, submits a form, opens an app screen).
- The browser or app opens a connection and sends the request.
- NGINX accepts it and passes it to an upstream server (your app, an API, a PHP-FPM pool).
- The upstream takes its time.
- Before NGINX sends a single byte back, the client closes the connection. Maybe the user hit back, maybe a timeout fired, maybe the phone lost signal.
- NGINX notices the closed socket, stops waiting (by default it also drops the upstream connection) and writes 499 to the access log.
Where the browser fits
The browser is the user's agent. It manages connections, timeouts and cancellations on the user's behalf.
When a user navigates away, the browser cancels in-flight requests for the old page. When JavaScript calls AbortController.abort(), the browser kills that fetch. Both look identical to NGINX.
Client-side vs. server-side
A 5xx means the server broke its side of the deal. A 4xx usually means the client sent something bad.
499 sits in an awkward spot. The client made the final move, so it lives in the 4xx range. The root cause is often on the server, because slow responses are what make clients give up.
So when you see a 499, the question isn't "who closed the connection?" You already know that. The question is "why did they stop waiting?"
How 499 differs from 408, 504 and other 5xx errors
The easiest way to keep these straight is to ask who gave up on whom.
| Code | Who gave up | What happened | Defined by |
|---|---|---|---|
| 499 Client Closed Request | The client | Client closed the connection before the server responded | NGINX (unofficial) |
| 408 Request Timeout | The server | Client was too slow sending the request, so the server closed the connection | RFC 9110 |
| 504 Gateway Timeout | The proxy | Proxy waited too long for the upstream server to respond | RFC 9110 |
| 500, 502, 503 | The server | Something broke, the upstream sent garbage or the service is unavailable | RFC 9110 |
Notice that 408 is the mirror image of 499. With 408, the client is slow and the server walks away. With 499, the server is slow and the client walks away.
The 499 vs. 504 race
This is the comparison that matters most in practice.
A slow upstream can produce either code. Which one you get depends on whose timer runs out first.
- If the client's timeout is shorter than NGINX's
proxy_read_timeout(60 seconds by default), the client leaves first and you log a 499. - If NGINX's timeout is shorter, NGINX gives up first, sends the client a 504 and logs a 504.
Same slow endpoint, two different codes. That's why a team can "fix" their 504s by raising proxy_read_timeout, then watch the 499s climb instead.
What makes 499 unique? It's the one code in the list where the server never got the chance to answer at all.
What causes 499s on web servers
Every 499 comes from one event. The connection closed before the response started.
What closed it varies a lot.
The user left. They closed the tab, hit back, clicked another link or quit the browser. The browser cancels whatever was still loading.
The network dropped. A phone switches from Wi-Fi to cellular, a train goes into a tunnel, a laptop goes to sleep. The TCP connection dies and NGINX eventually notices.
A timeout fired upstream of NGINX. A CDN, load balancer or API gateway in front of NGINX has its own timeout. When it gives up, NGINX sees that layer as the client and logs a 499.
Your app is waiting on someone else. The page calls a payment provider, a search API or a slow database query. Your server is stuck waiting, so the client is stuck waiting, and eventually the client stops.
Big transfers test people's patience. Large uploads and report exports take long enough that users assume something broke and try again.
An NGINX example
Say you have a reporting endpoint that runs a heavy query.
location /api/reports/ {
proxy_pass http://app_backend;
proxy_read_timeout 120s;
}
NGINX will wait up to two minutes. If the frontend uses a 30-second fetch timeout, every request that runs past 30 seconds becomes a 499. You'll never see a 504 for that endpoint, because the client always leaves first.
Humans vs. bots: who's closing the connection
Not every client gives up for the same reason. Splitting them into two groups makes the logs much easier to read.
People
Humans are impatient in predictable ways.
- They click a button, nothing happens, so they click it again (the first request becomes a 499).
- They refresh a page that feels stuck.
- They swipe an app closed or lock the phone mid-request.
- They navigate away from a single-page app while it's still fetching data.
Human 499s look scattered. Request times are all over the place because every person's patience runs out at a different moment.
Programs
Automated clients include API consumers, crawlers, uptime monitors, health checks and load-testing tools. They don't get bored. They hit a hard-coded timeout.
That gives them a fingerprint.
Programmatic 499s cluster at the same request time. If you see hundreds of 499s that all ended at 10.0 seconds, you're not looking at impatient users. You're looking at a client with a 10-second timeout.
The cool part?
That cluster tells you exactly how fast the endpoint needs to be for that client. Get under the line and the 499s disappear.
Reverse proxies, load balancers and gateways
Here's the part that trips up a lot of teams. To NGINX, the "client" is whatever opened the connection to it. That's often not a person.
How NGINX handles the disconnect
By default, NGINX watches the client connection while it waits on the upstream. When the client disappears, NGINX closes the upstream connection too and logs the 499.
The proxy_ignore_client_abort directive controls this. It's off by default. Turn it on and NGINX keeps the upstream request running even after the client leaves.
That's useful when the work must finish, like a write that shouldn't get cut off halfway. It also means your servers keep burning CPU on responses nobody will read.
Load balancers and WAFs
Put a load balancer, CDN or web application firewall in front of NGINX and the chain looks like this.
- User to CDN or WAF
- CDN or WAF to load balancer
- Load balancer to NGINX
- NGINX to your app
Each hop has its own timeout. If the load balancer's idle timeout fires before your app responds, the load balancer closes its connection to NGINX. NGINX logs a 499, even though the user may still be sitting there waiting.
AWS ALBs default to a 60-second idle timeout. If your NGINX proxy_read_timeout is longer than that, the ALB will always win the race.
Proxy timeouts worth knowing
proxy_connect_timeoutis how long NGINX waits to open a connection to the upstream.proxy_read_timeoutis how long NGINX waits between reads from the upstream.proxy_send_timeoutis how long NGINX waits between writes to the upstream.client_body_timeoutandclient_header_timeoutcover slow clients sending the request (these produce 408s, not 499s).
Service meshes and microservices
In a microservices setup, every service sits behind a sidecar proxy or an internal gateway. That multiplies the number of hops, and every hop can log its own 499 when the caller above it gives up. More on that below.
How to troubleshoot 499s
Start with the logs. Every 499 investigation comes down to three questions.
- Where are they happening (which URLs)?
- Who's triggering them (which user agents and IPs)?
- How long did the request run before the client left?
How this works
- Filter the access log to 499s only.
- Count them by URL to find the hot endpoints.
- Count them by user agent to split humans from bots.
- Check request times to spot timeout clusters.
These commands assume NGINX's default combined log format, where the status code is field 9 and the URL is field 7.
# Top 20 URLs returning 499
awk '$9 == 499 {print $7}' access.log | sort | uniq -c | sort -rn | head -20
# Top 20 user agents behind those 499s
awk -F'"' '$3 ~ / 499 / {print $6}' access.log | sort | uniq -c | sort -rn | head -20
# 499s per hour, to see when they spike
awk '$9 == 499 {print substr($4, 2, 14)}' access.log | sort | uniq -c
That's enough to tell you whether you have one slow endpoint, one aggressive bot or a site-wide latency problem.
Pattern analysis
- One or two URLs dominate. The endpoint is slow. Profile it.
- One user agent dominates. A client has a short timeout. Check its config or talk to its owner.
- 499s spread across every URL. Look at infrastructure (database, upstream pool, a load balancer timeout).
- Spikes at the same time each day. Look at traffic peaks, cron jobs and batch work competing for resources.
Tools
- Log analyzers like GoAccess, or a quick load into BigQuery or DuckDB for big files
- APM tools (Datadog APM, New Relic, Elastic APM) to see which span was slow when the client left
- Network monitors and packet captures (tcpdump, Wireshark) when you need to prove who sent the FIN or RST
The logs tell you where to look. The APM tells you why it's slow.
What 499s cost you
A handful of 499s is normal background noise. A rising share of them is a performance problem showing up in a place most dashboards ignore.
Wasted server resources
With proxy_ignore_client_abort off, NGINX drops the upstream connection when the client leaves. That doesn't always stop your app. Many app servers keep running the request until they try to write the response and find the socket closed.
So the database query still runs. The PDF still renders. A worker thread stays busy on a response that goes straight in the trash, and that thread isn't available for the next real user.
Error rates that lie
If your monitoring counts every 4xx as an error, 499s pad the number with events that aren't bugs. Teams then learn to ignore the error rate, which is worse than having no error rate at all.
The opposite mistake happens too. Filter out 499s entirely and you hide the one signal that says users are giving up.
SEO and user experience
This is the part I care about most.
When Googlebot requests a URL and disconnects before your server answers, NGINX logs a 499 with Googlebot's user agent. Googlebot didn't get the page. That fetch was wasted.
Google's crawl budget documentation says its crawl capacity limit goes down when a site slows down or returns server errors. So slow responses cost you twice. The current fetch fails, and future crawling slows down.
The same applies to AI crawlers. If GPTBot, ClaudeBot or PerplexityBot give up on your pages, that content doesn't make it into their index either.
What should you do with that?
Filter your 499s by crawler user agent, verify the IPs against the published ranges (user agents are easy to fake) and look at which templates they're failing on. On big sites, it's usually a small number of slow templates, like faceted category pages or internal search.
For users, a 499 is a person who decided your site wasn't worth waiting for. You don't see them in your analytics because the page never loaded far enough to fire the tag.
Logging and monitoring 499s
The default combined log format leaves out the one field you need most, which is how long the request ran.
What to log
- Request URI
- User agent
- Client IP (and the real client IP from
X-Forwarded-Forif you sit behind a proxy) $request_time, the total time NGINX spent on the request$upstream_response_timeand$upstream_addr, to see which backend was slow$request_id, so you can match the log line to an APM trace- A session or user ID if your privacy setup allows it
Here's a log format that covers it.
log_format timed '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" '
'rt=$request_time urt=$upstream_response_time '
'ua=$upstream_addr rid=$request_id';
access_log /var/log/nginx/access.log timed;
Now every 499 tells you how long the client waited before it bailed.
Analyzing 499s in access logs
Once you have rt=, sort 499s by request time and look at the distribution. A smooth spread points to human impatience. A tall spike at one value points to a client timeout.
Dashboards and alerts
Alert on the 499 rate as a percentage of total requests, per endpoint, compared with that endpoint's own baseline. Raw counts are useless because they rise with traffic.
A sudden jump on one endpoint usually means a deploy made it slower. A slow climb across the site usually means capacity is running out.
Integrating with monitoring tools
- Datadog. Parse
statusandrtin a log pipeline, then build a log-based metric for 499s per endpoint. - Prometheus. If you run ingress-nginx on Kubernetes, its request metric carries a status label, so you can graph 499s directly. On plain NGINX, use a log exporter to turn status codes into metrics.
- Elastic, Splunk or BigQuery. Ship the access logs and run the same URL, user agent and request time breakdowns as above.
Keep 499s as their own series. Don't lump them into "4xx" or "errors."
How to prevent 499s
You can't stop people from closing tabs. You can make sure they rarely have a reason to.
1. Make the slow endpoints fast
This fixes most 499 problems. Use the URL breakdown from your logs, then profile the top offenders. Look for missing database indexes, N+1 queries, uncached third-party calls and work that could run in the background.
If a report takes 45 seconds to build, don't make the user wait on an open connection. Queue the job, return a 202 right away and let the client poll for the result or get notified when it's ready.
2. Fix the client code
- Disable submit buttons after the first click so users can't fire duplicate requests.
- Cancel stale requests on purpose (search-as-you-type is the classic case), and accept that those show up as 499s.
- Set fetch timeouts that match how long the endpoint actually takes.
- Retry with backoff instead of hammering the server.
3. Show progress
People wait longer when they can see something happening. Skeleton screens, progress bars and "we're building your report" messages buy you seconds of patience. A frozen spinner does the opposite.
4. Get your keep-alive settings in order
Reusing connections cuts the cost of TCP and TLS handshakes on every request. Make sure each layer's keep-alive timeout is longer than the idle timeout of the layer in front of it. If NGINX or your app closes idle connections before the load balancer does, the load balancer can send a request down a connection that's already dead.
5. Line up your proxy timeouts
Timeouts should get shorter as you go deeper into the stack. The CDN waits longest, then the load balancer, then NGINX, then your app, then your database.
Why? When the innermost layer gives up first, it returns a real error the outer layers can handle. When the outer layer gives up first, everything below it keeps working on a request nobody is waiting for, and you get a 499 instead of a useful error message.
6. Decide what should finish without the client
For work that must complete (a payment, an order, a write to an external system), you have two options.
- Turn on
proxy_ignore_client_abortfor that location so NGINX lets the upstream finish. - Better yet, make the operation idempotent and move it to a background job, so a dropped connection never leaves things half done.
Updating API clients to handle 499s
Here's the twist. An NGINX 499 never reaches the client that caused it. The client hung up, so there's nobody to deliver it to.
What your client sees instead is its own error, like a timeout exception, an AbortError from fetch or a "connection reset" from the network stack.
There's one exception worth knowing. Google's API design maps the gRPC CANCELLED code to HTTP 499, and some gateways and services pass a 499 back to an internal caller. If your client talks to systems like that, it can receive one.
How clients should react
- Treat your own cancellations as normal behavior, not failures. A user who navigated away doesn't need an error toast.
- Treat timeouts as "unknown outcome." The server may have finished the work after you left.
- If you do receive a 499 from a gateway, read it as "the request was cancelled," not "the server is broken."
Backoff and retry
Retry only when it's safe.
- GET, HEAD and other idempotent requests can retry.
- For writes, send an idempotency key so the server can recognize a repeat and skip it.
- Use exponential backoff with jitter so a thousand clients don't retry at the exact same moment.
- Cap the number of retries. Infinite retries on a slow endpoint just turn a slowdown into an outage.
Error handling in SDKs and libraries
If you maintain an SDK, give callers separate error types for "you cancelled this," "we timed out" and "the server returned an error." Lumping them together pushes every downstream team into guessing.
And make timeouts configurable per call. A default that's fine for a lookup will be wrong for an export.
Where 499s show up in the real world
These are the scenarios that produce most 499s, along with what to look for and what to do about each.
| Scenario | What the logs show | What to do |
|---|---|---|
| Large file download interrupted by the user | 499s (or 200s with short byte counts) on file URLs with long request times | Serve files from a CDN or object storage and support range requests so downloads can resume |
| Streaming API where the client disconnects early | 499s on streaming or long-poll endpoints, often with very long request times | Usually expected behavior. Exclude these endpoints from error alerts and make sure the server stops work on disconnect |
| Mobile connection drops mid-request | Scattered 499s from mobile user agents, heavier on large responses | Shrink payloads, paginate and make requests safe to retry |
| SPA navigation cancels in-flight requests | Bursts of 499s on API endpoints right after page-view requests from the same IP | Cancel stale requests on purpose and stop counting them as errors |
| Search-as-you-type | Many 499s on the search endpoint, each followed by a new request a moment later | Debounce input so you send fewer requests in the first place |
The SPA and search cases are the ones that make teams panic. They look terrible in a dashboard and they're mostly the frontend working as designed.
499s in microservices architectures
In a monolith, a 499 has one client and one server. In microservices, one user request can fan out into a dozen internal calls, and each hop can log its own 499.
It's like a game of telephone where one person hangs up and everybody down the line keeps talking.
Distributed tracing
You can't debug this from one service's logs. You need a trace ID that travels with the request.
- Pass a
traceparentheader (W3C Trace Context) or your own request ID through every hop. - Log that ID in NGINX with
$request_idor the incoming header. - In your tracing tool, find the span where the cancellation started. That's the service whose caller gave up first, and its slowest child span is usually the real culprit.
Timeout misalignment between services
Here's a common setup that guarantees 499s.
Service A calls Service B with a 2-second timeout. Service B calls Service C with a 5-second timeout. When C takes 3 seconds, A gives up, B's proxy logs a 499 and B keeps waiting on C for a result that nobody will use.
The fix is the same rule as before. Each downstream call gets a shorter timeout than the one above it.
Best practices for resilient service calls
- Propagate deadlines, not just timeouts. gRPC does this natively, so each service knows how much time is left in the overall request.
- Check for cancellation in long-running handlers and stop work when the caller is gone.
- Use circuit breakers so one slow dependency doesn't drag every caller into a 499 spiral.
- Keep retries at one layer. If every layer retries three times, a single slow call turns into dozens of requests.
Common mistakes with 499s
Blaming the backend for client impatience (and the reverse)
Not every 499 is a backend problem. Search-as-you-type, SPA navigation and streaming endpoints all produce 499s by design.
Not every 499 is harmless either. If one endpoint's 499 rate doubles after a deploy, that's a regression, no matter how normal 499s are in general.
The request time column settles most of these arguments. A 499 after 80 milliseconds is someone typing. A 499 after 30 seconds is someone giving up.
Overlooking latency between services
Teams profile the app code and forget the network. Cross-region database calls, DNS lookups, TLS handshakes to third-party APIs and cold starts on serverless functions all add time the app's own profiler doesn't show. Compare $request_time with $upstream_response_time to see how much of the wait happened outside your app.
Debugging under load in production
499s often only appear under real traffic, which makes them hard to reproduce on a laptop.
You can force one on purpose to make sure your logging and alerts catch it.
curl --max-time 2 https://staging.example.com/api/reports/annual
If that endpoint takes longer than 2 seconds, curl hangs up and NGINX logs a 499. Now you can confirm the log line, the trace and the dashboard all show what you expect.
For production, lean on sampling and percentiles. Look at p95 and p99 request times for the endpoints with the most 499s, not the average. Averages hide exactly the slow requests that make people leave.
What to do on Monday
A 499 doesn't mean your server broke. It means somebody stopped waiting for it, and that's worth knowing.
For developers
- Find your top five endpoints by 499 count and profile the slowest one.
- Move anything that takes more than a few seconds into a background job.
- Debounce search inputs and cancel stale requests on purpose.
For DevOps and SRE
- Add
$request_time,$upstream_response_timeand$request_idto your NGINX log format. - Write down every timeout in the chain, from CDN to database, and make sure they shrink as you go deeper.
- Graph 499s as their own series, per endpoint, as a share of requests.
For API builders
- Give SDK users separate error types for cancellations, timeouts and server errors.
- Require idempotency keys on writes so retries are safe.
- Propagate deadlines between services.
For SEOs
- Filter your 499s by verified Googlebot and AI crawler IPs.
- Map them to page templates and hand the slowest templates to your dev team.
Happy log diving.
AI Disclosure: The content on this page was written by myself, John McAlpin. However, some of the design elements were created with the assistance of AI.