Upstream timed out (110: Connection timed out) while reading response header from upstream
Today I was investigating a weird nginx upstream timed out error I found on the server logs:
Upstream timed out (110: Connection timed out) while reading response header from upstream
This nginx timeout error was located in an nginx – apache proxy server, where nginx is serving all static content and apache all the dynamic.
Nginx Upstream Timed Out Scenarios
Investigating the error and after trying a few fixes, I found this error can happen in two scenarios:
1) Nginx as Proxy, like the one happened to me.
Try adding proxy_read_timeout
option into your virtual host configuration, it should look like this:
proxy_read_timeout 150;
Place it inside your root location config:
location / { ... proxy_read_timeout 150; ... }
2) Nginx as standalone server with php-fpm or another upstream application.
If this is your case, try adding fastcgi_read_timeout
option:
fastcgi_read_timeout 150;
With your php-fpm configuration it should look like this:
location ~* .php$ { include fastcgi_params; fastcgi_index index.php; fastcgi_read_timeout 150; fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; }
On both cases, just restart nginx to apply the changes.
Note: some scripts may need to increase/decrease the “150” value I posted here.
Additional Resources
Popular search terms:
- upstream request timeout
- nginx upstream timed out
- upstream timed out (110: Connection timed out) while reading response header from upstream
- upstream timed out