nginx proxy_error ai_generated true

upstream timed out (110: Operation timed out) while reading response header from upstream, client: 10.0.0.1, server: example.com

ID: nginx/proxy-read-timeout

Also available as: JSON · Markdown
82%Fix Rate
87%Confidence
3Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
1 active

Root Cause

504 Gateway Timeout. Backend did not send response headers within proxy_read_timeout (default 60s). Long-running request or backend issue.

generic

Workarounds

  1. 88% success Increase proxy_read_timeout for specific slow endpoints only
    location /api/reports { proxy_read_timeout 300s; proxy_pass http://backend; }  # only slow endpoints get longer timeout

    Sources: https://nginx.org/en/docs/http/ngx_http_core_module.html

  2. 92% success Fix the slow backend response (optimize query, add caching)
    Profile backend: slow query log, APM tracing. Add caching for expensive operations. 504 means the backend is too slow.
  3. 82% success Implement request buffering and async processing for long operations
    Return 202 Accepted immediately; process in background; client polls /status endpoint. Avoids tying up nginx and backend workers.

Dead Ends

Common approaches that don't work:

  1. Set proxy_read_timeout to 3600 or higher globally 75% fail

    Extremely long timeouts mask backend failures and tie up nginx worker connections for the duration. Set per-location for specific slow endpoints.

  2. Add keepalive connections assuming the timeout is a connection issue 80% fail

    proxy_read_timeout is about response time, not connection establishment. Keepalive helps with proxy_connect_timeout, not read timeout.