How to fix upstream timed out (110: Connection timed out) error in Nginx

When you come across "Upstream timed out (110: Connection timed out)" error in your Nginx log:

[error] upstream timed out (110: Connection timed out) while reading response header from upstream, 
client:, server:, request: "GET / HTTP/1.1", upstream: "", host: "", referrer: "requested_url"

That means it takes your web server more than 60 seconds to respond. To solve this problem in nginx.conf change the value of proxy_read_timeout directive. This directive determines how long nginx will wait to get the response to a request. By default it's 60 seconds. Change it to 300 seconds:

server {
    listen       80;
    location / {
        proxy_read_timeout 300;

This should fix the problem.

2012-10-09 16:52:08
you crazy? 5minuts time out o_O
2012-10-09 16:53:31
Why not?
2012-10-09 16:54:17
nice advice thanks, now my apaches are allways in "server reached MaxClients"
2012-10-09 16:58:43
Then you probably have a problem on application side and you need to fix this instead of tuning timeouts. You only need to touch timeouts if you know that your application needs it (i.e. uploading huge files or launching heavy processing scripts/parsers, etc)
2012-11-26 01:25:23
Why would you tie up nginx with a client request for 5 min!! You're just asking for an easy way to DDoS your site. Set sane timeouts. If your server doesn't respond in 5 seconds, you have a much bigger issue.
2012-11-26 05:19:43
The previous comment answers to your question
2013-04-27 18:01:18
Or make it location specific timeout if you know that one URL needs longer to process, but don't put that in the root location block. For example - we have a reporting url that takes a long time - so we set this url specifically with a different timeout - that way the DDoS is limited (the attacker would have to know to hit that url).
2013-06-12 22:51:28
Call me crazy, but the ddos talk is unwarranted. I can send 10k connections to your server in 30s just as easily as I can send them in 300s. If you're worried about dns, you should be looking at a thorttling setting that makes sense.
2014-08-04 19:09:53
this "solution" is almost as awesome as the one i saw saying the way to fix php errors is to turn off error logging
2014-09-22 16:32:51
Actually this solution was useful to me as I'm using Nginx only as an http load balancer in front of a bunch of internal corporate J2EE interactive reporting apps that can take quite some time to process their requests.
Yuan Yuan
2014-10-03 10:18:04
Thank you all upstairs, you all spoke out what I want to ask
2014-11-04 22:10:43
Does not work for me.
2014-11-23 13:19:05
Does not work for me either.
2014-12-16 07:54:50
Does not work for me to.

Got a comment?
Name (optional):
Anti-Bot:captcha =
Copyright © 2012-2013 HowToUnix - *nix Howtos and Tutorials
All Rights Reserved.