upstream timed out (110: Connection timed out) while reading response header from upstream
The backend took too long to respond
Seen in nginx error log (shown to visitors as 504 Gateway Timeout)
nginx connected to the backend but did not receive response headers within proxy_read_timeout (60 seconds by default).
Common causes
- A slow request in the application: long database queries, external API calls or heavy reports.
- The backend is overloaded or all its workers are busy.
- The backend is stuck or deadlocked and accepts connections without answering.
How to fix it
- Find and fix the slow request using the request and upstream fields in the log line.
- If long requests are expected, raise the timeout for that location: proxy_read_timeout 300s; (fastcgi_read_timeout for PHP-FPM).
- Add backend capacity (more workers or instances), or move long jobs to a background queue.
Got a different message? Paste it into the error explainer.
Related errors
- connect() failed (111: Connection refused) while connecting to upstream · The backend is not listening
- connect() to 127.0.0.1:8080 failed (13: Permission denied) while connecting to upstream · nginx is not allowed to connect to the backend
- no live upstreams while connecting to upstream · Every backend server is marked as down
- upstream prematurely closed connection while reading response header from upstream · The backend closed the connection without answering
- client intended to send too large body · An upload exceeded client_max_body_size
- bind() to 0.0.0.0:80 failed (98: Address already in use) · Another process already uses the port
- could not build server_names_hash, you should increase server_names_hash_bucket_size · A server_name is too long for the hash table
- AH00558: Could not reliably determine the server's fully qualified domain name · Apache has no global ServerName
- AH01630: client denied by server configuration · Apache access rules blocked the request
- (98)Address already in use: AH00072: make_sock: could not bind to address [::]:80 · Apache cannot listen on the port
- too many certificates already issued for exact set of domains · Let's Encrypt rate limit reached
- SSL_do_handshake() failed while SSL handshaking to upstream · nginx couldn't complete TLS with the backend