Nginx upstream timed out

Nginx upstream timed out (why and how to fix)

Nginx upstream timed out (110: Connection timed out) while reading response header from upstream is pretty common error. Lets find out why it happens and how to avoid it.

When you get this error, it usually means your upstream is slow and while there are couple easy fixes which I’ll show below, the proper solution is to figure out why it’s slow and improve the speed of upstream service.

There are two main directives responsible for Nginx upstream timed out (110: Connection timed out) error:

  • proxy_read_timeout – Defines a timeout for reading a response from the proxied server. Default is 60 seconds.

    ..... location ~ ^/slow-proxy { proxy_read_timeout 180; # <--- proxy_pass ...; } .....

    * you can use proxy_read_timeout inside http, server and location blocks.

  • fastcgi_read_timeout – Defines a timeout for reading a response from the FastCGI server. Default is 60 seconds.


    ..... location ~ \.php$ { fastcgi_read_timeout 180; # <--- fastcgi_pass ...; } .....

    * you can use fastcgi_read_timeout inside http, server and location blocks.

    This is commonly overlooked directive used for running fastcgi services (PHP-FPM for example). I see people first trying to adjust proxy_read_timeout directive. When that doesn’t help they start tweaking all possible timeout related options they can find in the docs (send_timeout, client_body_timeout etc) and then get mad at Nginx. I know, I’ve been there myself.. 🙂

    The trick here is to look in the Nginx error_log and see what exactly error message says. Specifically upstream: part which could tell us if it’s regular proxy upstream: "http://my-awesome-proxy" or fastcgi upstream: "fastcgi://127.0.0.1:9000". Once you know which upstream type you are dealing with, you can accordingly adjust either proxy_read_timeout or fastcgi_read_timeout.


Let me repeat the initial point one more time. While you can easily increase timeouts and “hide” the Nginx upstream timed out (110: Connection timed out) while reading response header from upstream from your logs, the clients and your users will be experiencing big delay. In most case when you see this error (response not generated within default 60 seconds window), it means you need to look what happens in your upstreams (apps) and fix underlying problems.

Want faster website?

I'm Sergey Khaladzinski (@gansbrest). I regularly share tips and tricks to improve websites performance. My main focus at the moment is monitoring, servers and backend performance. If you liked this article, join my list to get updates from me in the future.

Directly from me. No spam guaranteed. Unsubscribe at any time. Powered by ConvertKit

Leave a Reply

Your email address will not be published. Required fields are marked *