VPS Tutorials
How to Troubleshoot Nginx 499 Client Closed Request
Read Nginx timings and compare four local test cases to tell client deadlines, proxy timeouts, and slow upstream responses apart.

An Nginx access log entry for 499 Client Closed Request means the peer disconnected before Nginx began sending the response headers. On a VPS behind a CDN or load balancer, that peer can be the proxy immediately in front of Nginx. The visitor may get a timeout page while the origin records 499. Start by identifying the hop that stopped waiting. How the Nginx source defines 499
A few canceled requests can be part of normal traffic. A visitor might navigate away, or a search box might cancel an older request as the user types. Investigate when a particular endpoint starts logging more 499s, or when many of the canceled requests end at roughly the same time.
| Pattern on the same route | Where to look first |
|---|---|
| Short, scattered cancellations that line up with navigation | Browser Network panel and any cancellation events in the application |
| Many requests end at nearly the same elapsed time | Browser or SDK deadlines, then the timeouts and logs of the proxy in front |
| Comparable completed requests also get slower, or 504s appear | Time to upstream headers, application queues, database queries, and external calls |
Count 499s against all requests for the same route, method, and time window. Keep successful or otherwise completed requests in your sample so you can compare timings. A sitewide rate can hide a problem that affects only report previews.
Find the effective access_log for the virtual host first. The default combined format records the status but leaves out the timings needed here. Define this temporary format within your existing http { ... } block.
log_format timeout_trace 't=$time_iso8601 method=$request_method route="$uri" '
'status=$status rt=$request_time uct="$upstream_connect_time" '
'uht="$upstream_header_time" urt="$upstream_response_time" '
'us="$upstream_status" id=$request_id';
Add the following directive in the server or location you are investigating. If that block inherits its regular log from a parent, keep the existing logging directive explicitly at the same level as the new one.
access_log /var/log/nginx/timeout-trace.log timeout_trace;
On a Linux VPS where systemd manages Nginx, test the configuration and reload it. Use your normal log directory and rotation setup. Remove the extra directive after you have captured enough samples.
sudo nginx -t && sudo systemctl reload nginx
sudo tail -n 2000 /var/log/nginx/timeout-trace.log |
awk '/(^| )status=499( |$)/'
rt is the time from when Nginx starts reading the request to when it writes the log entry. uct measures connection setup to the upstream. uht measures the time to receive upstream headers, and urt records upstream response timing. Multiple upstream attempts can yield comma- or colon-separated values. Nginx access log variables · Nginx upstream variables
In a line with uct=0.000 uht="-" urt="0.505", the upstream connection was quick and no complete upstream header was recorded. The response timer ran until the request ended, so the 0.505 seconds on this canceled request cannot tell you when the application would have finished. Trace its queue, start, and completion times using a request ID that the gateway and application both propagate and log. Remove private paths, parameters, and credentials before sharing logs.
For this test, I ran Nginx 1.19.6 and a Python backend on loopback. The backend waited 1.5 seconds before sending headers. Each run made one read-only request. The fourth added a front proxy with a 600 ms upstream read timeout so both Nginx logs could be compared.
| Test condition | What curl saw | What origin Nginx logged |
|---|---|---|
| curl had a 0.5 s deadline, origin could wait 4 s | 000, exit code 28 | 499 at 0.505 s |
| Same path, curl had a 4 s deadline | 200 | 200 at 1.505 s |
| Origin proxy timed out after 600 ms, curl could wait 4 s | 504 | 504 at 0.601 s |
| Front proxy timed out after 600 ms, origin could wait 4 s | 504 | 499 at 0.601 s, with 504 in the front proxy log |
In the first run, 000 is curl's display value when it has no HTTP status to report. In the fourth, the front proxy closed the connection to the origin and delivered a 504 to curl. Its logged upstream status, us="504", came from its own timeout while it was still waiting for headers. To check your own stack, choose an equivalent read-only path in staging and repeat the same request with two different deadlines. Replace the example host below.
url='https://staging.example.test/reports/sample'
for limit in 2 8; do
curl -sS -o /dev/null --max-time "$limit" \
-w "limit=$limit http=%{http_code} connect=%{time_connect} first_byte=%{time_starttransfer} total=%{time_total}\n" "$url"
printf 'exit=%s\n' "$?"
done
--max-time sets the time allowed for the whole transfer. The test deadlines give you a way to vary one condition at a time. For a live incident, compare those timings against the actual deadlines in your client and gateway. curl --max-time manual · Google Apigee 499 troubleshooting example
- The client or SDK hits a deadline. Check the total request budget, browser cancellation logic, and retries. If a healthy request regularly needs longer than the client currently allows, adjust the deadline for that call. For an operation that can write data, check its outcome before retrying.
- A front proxy times out. Compare the same request in the front and origin logs. List the connection, idle, and total timeouts that actually apply. Leave enough room for the origin to complete or return a controlled error before a proxy or client gives up.
- The application is slow. Compare upstream header timings from completed requests with queue, database, and dependency timings. For long report exports, consider creating a job and returning its ID promptly. Let the caller check job status and retrieve the finished export separately.
proxy_read_timeout governs the gap between reads from the upstream. Each connection in the chain can have a different idle or total limit. Raising this Nginx setting cannot bring back a client that has already left. proxy_ignore_client_abort on changes whether Nginx keeps the upstream connection open after the client disconnects. For work with side effects, check whether it can be canceled safely and how the application handles duplicate attempts. Nginx upstream read timeout · Nginx behavior on client disconnect
After the change, repeat the read-only request under similar load. Confirm that callers receive a usable result and that the operation finishes as expected. Track the 499 and 504 rates and time to first byte for the route. If 504s rise as 499s fall, follow the timeout to the hop that now reports it.
- Correlate system, Nginx, and application events with the guide to reading logs on a VPS.
- If callers receive a gateway error, use the 502 and 504 troubleshooting checklist for Nginx, PHP-FPM, and Gunicorn.
- If the edge sends a Cloudflare 524, check origin timing and async jobs for long requests.
Next step: compare the actual plans
Filter the listed plans by budget, specifications and region, or start with a buying guide.