# Upstream timeout issue

**URL:** <https://www.ruby-forum.com/t/upstream-timeout-issue/201528>\
**Category:** NGINX\
**Created:** [January 10, 2011, 10:02am UTC](https://www.ruby-forum.com/t/upstream-timeout-issue/201528 "2011-01-10T10:02:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [January 10, 2011, 10:02am UTC](https://www.ruby-forum.com/t/upstream-timeout-issue/201528/1 "2011-01-10T10:02:11Z")

</div>

I setup an upstream configuration with only one server for now, i will  
add a new one in a while.

im experiencing a strange error now and then when users are uploading  
files to a form they get sometimes in the browser ERROR 502 bad  
gateway  
and on nginx error logs i get

```auto

2011/01/10 08:07:31 [error] 28135#0: *606977 upstream timed out (110:
Connection timed out) while reading response header from upstream,
client: XXX.XXX.XXX.XXX, server: , request: "POST
/UserDetails.aspx?CultureId=1 HTTP/1.1", upstream:
"http://backend1:80//UserDetails.aspx?CultureId=1", host:
"host.host.com", referrer:
"http://host.host.com/UserDetails.aspx?CultureId=1"

2011/01/10 08:07:31 [error] 28135#0: *606977 no live upstreams while
connecting to upstream, client: XXX.XXX.XXX.XXX, server: , request:
"POST /UserDetails.aspx?CultureId=1 HTTP/1.1", upstream:
"http://backend/UserDetails.aspx?CultureId=1", host: "host.host.com",
referrer: "http://host.host.com/UserDetails.aspx?CultureId=1"
```

now i dont know what is the exact issue, or the upload timeout or maybe  
DNS issues…could it be IPv6 dns resolving the problem?

When the users upload directly to the server they dont get any timeout  
or errors.

Thanks in advance

Posted at Nginx Forum:

> **[Upstream timeout issue](https://forum.nginx.org/read.php?2,165055,165055#msg-165055)**
>
> I setup an upstream configuration with only one server for now, i will add a new one in a while. im experiencing a strange error now and then when users are uploading files to a form they get sometimes in the browser ERROR 502 bad gateway and on...

---

<div class="post-metadata">

**Author:** ![elgreco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/90db22/32.png) [@elgreco](https://www.ruby-forum.com/u/elgreco)\
**Post date:** [January 10, 2011, 10:05am UTC](https://www.ruby-forum.com/t/upstream-timeout-issue/201528/2 "2011-01-10T10:05:19Z")

</div>

I forgot to attach the nginx.conf gile

```auto
       gzip on;
        gzip_disable "msie6";

        # gzip_vary on;
        # gzip_proxied any;
         gzip_comp_level 6;
         gzip_buffers 16 8k;
         gzip_http_version 1.1;
         gzip_types text/plain text/css application/json
application/x-javascript text/xml application/xml application/xml+rss
text/javascript;

        ##
        # Balancer
        ##
        upstream backend {
        server XXX.XXX.XXX.XXX;

        }

        server {
          listen 80;
                location / {

                client_max_body_size 50M;
                client_body_buffer_size 256k;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For
$proxy_add_x_forwarded_for;
                proxy_set_header Host $host;
                proxy_pass http://backend;
                }
        }
```

## egreco Wrote:

> timed out (110: Connection timed out) while  
> XXX.XXX.XXX.XXX, server: , request: "POST
> 
> When the users upload directly to the server they  
> dont get any timeout or errors.
> 
> Thanks in advance

Posted at Nginx Forum:  
[http://forum.nginx.org/read.php?2,165055,165056#msg-165056](http://forum.nginx.org/read.php?2,165055,165056#msg-165056)

---

<div class="post-metadata">

**Author:** ![elgreco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/90db22/32.png) [@elgreco](https://www.ruby-forum.com/u/elgreco)\
**Post date:** [January 10, 2011, 2:39pm UTC](https://www.ruby-forum.com/t/upstream-timeout-issue/201528/3 "2011-01-10T14:39:26Z")

</div>

i added:

```auto
                proxy_connect_timeout 180;
                proxy_send_timeout 180;
                proxy_read_timeout 180;

```

and i see less { (110: Connection timed out) while reading response  
header from upstream, } errors.

can i do something more to get rid of the timeouts?

Posted at Nginx Forum:

> **[Re: Upstream timeout issue](https://forum.nginx.org/read.php?2,165055,165099#msg-165099)**
>
> I setup an upstream configuration with only one server for now, i will add a new one in a while. im experiencing a strange error now and then when users are uploading files to a form they get sometimes in the browser ERROR 502 bad gateway and on...

---

<div class="post-metadata">

**Author:** ![elgreco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/90db22/32.png) [@elgreco](https://www.ruby-forum.com/u/elgreco)\
**Post date:** [March 16, 2011, 11:37am UTC](https://www.ruby-forum.com/t/upstream-timeout-issue/201528/4 "2011-03-16T11:37:32Z")

</div>

Great that you fixed it… but how? Is it possible to write the  
solution?  
thanks

Posted at Nginx Forum:

> **[Re: Upstream timeout issue](https://forum.nginx.org/read.php?2,165055,183229#msg-183229)**
>
> I setup an upstream configuration with only one server for now, i will add a new one in a while. im experiencing a strange error now and then when users are uploading files to a form they get sometimes in the browser ERROR 502 bad gateway and on...

---

<div class="post-metadata">

**Author:** ![elgreco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/90db22/32.png) [@elgreco](https://www.ruby-forum.com/u/elgreco)\
**Post date:** [January 11, 2011, 9:25am UTC](https://www.ruby-forum.com/t/upstream-timeout-issue/201528/5 "2011-01-11T09:25:04Z")

</div>

Its fixed

## elgreco Wrote:

> timed out (110: Connection timed out) while  
> XXX.XXX.XXX.XXX, server: , request: "POST
> 
> When the users upload directly to the server they  
> dont get any timeout or errors.
> 
> Thanks in advance

Posted at Nginx Forum:  
[http://forum.nginx.org/read.php?2,165055,165301#msg-165301](http://forum.nginx.org/read.php?2,165055,165301#msg-165301)
