# Upstream timed out

**URL:** <https://www.ruby-forum.com/t/upstream-timed-out/218840>\
**Category:** NGINX\
**Created:** [April 13, 2012, 11:00am UTC](https://www.ruby-forum.com/t/upstream-timed-out/218840 "2012-04-13T11:00:30Z")\
**Posts on this page:** 3\
**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:** [April 13, 2012, 11:00am UTC](https://www.ruby-forum.com/t/upstream-timed-out/218840/1 "2012-04-13T11:00:30Z")

</div>

Hi.

I’m the new admin of a website and its servers. I have a frontend nginx  
proxy server and an Apache backend.  
I sometimes have errors :

2012/04/12 17:44:33 [error] 13442#0: \*74193485 upstream timed out (110:  
Connection timed out) while reading response header from upstream,  
client: 98.87.76.65, server: www.mysite.tld, request: “POST /my/url  
HTTP/1.1”, upstream: “[http://12.23.34.45:80/my/url](http://12.23.34.45:80/my/url)”, host:  
“www.mysite.tld”, referrer: “[https://www.mysite.tld/another/url](https://www.mysite.tld/another/url)”  
2012/04/12 17:44:33 [error] 13442#0: \*74193485 no live upstreams while  
connecting to upstream, client: 98.87.76.65, server: www.mysite.tld,  
request: “POST /my/url HTTP/1.1”, upstream: “[http://backend/my/url](http://backend/my/url)”,  
host: “www.mysite.tld”, referrer: “[https://www.goeland.fr/another/url](https://www.goeland.fr/another/url)”

(I’ve juste anonymized the urls and ip addresses)

Here are the configuration files :

conf.d/proxy.conf :

proxy\_redirect off;  
proxy\_set\_header Host $host;  
proxy\_set\_header X-Real-IP $remote\_addr;  
proxy\_set\_header X-Forwarded-For  
$proxy\_add\_x\_forwarded\_for;  
proxy\_set\_header X-Forwarded-Proto $scheme;  
client\_max\_body\_size 32M;  
client\_body\_buffer\_size 256k;  
client\_header\_buffer\_size 128k;  
proxy\_connect\_timeout 30;  
proxy\_send\_timeout 30;  
proxy\_read\_timeout 30;  
proxy\_buffer\_size 32k;  
proxy\_buffers 64 32k;  
proxy\_busy\_buffers\_size 128k;

conf.d/loadbalancer.conf :

upstream backend {  
ip\_hash;  
# web1

# server 127.0.0.1:8098 backup;

```
# web2
server 44.33.22.11;
#web3
server 11.22.33.44 down;

```

}

sites-enabled/mysite.conf :

server {  
listen 80;  
listen 443 ssl;  
server\_name www.mysite.tld www3.mysite.tld;

```
    access_log off; #/home/nginx/log/mysite.access.log;
    #error_log /dev/null crit;

    # Possible level values : debug | info | notice | warn | error |

```

crit  
error\_log /home/nginx/log/mysite.error.log notice;  
log\_not\_found off;

```
    #set $proto "http";
    #if ( $server_port = "443" ) {
     #set $proto "https";
    #}

    # serve static files directly
    location ~*

```

^.+.(jpg|jpeg|gif|css|png|js|ico|html|pdf|zip|tgz|gz|bz2|swf)$ {  
expires 10d;  
root /home/mysite/www;  
}

```
    location / {
            #proxy_set_header X-Forwarded-Proto $proto;
            proxy_pass http://backend;
            add_header X-Whom removed_email_address@domain.invalid;
    }

    error_page 405 = $uri;
    error_page 500 502 503 504 /50x.html;

    location = /50x.html {
            root /home/mysitewww;
    }

   location = /favicon.ico { access_log off; log_not_found off; }

```

}

The problem seems to be recent and sometimes happens immediatly after  
clients have paid through the bank online credit card form which is  
integrated (we do not redirect to the bank website). It’s a real problem  
for us since when it happens at that moment, clients think their order  
and paiement have not been saved and they order a second time (and also  
pay a second time).

I don’t really know what i’m looking for : can it be a network  
connection problem between frontend and backend servers ? Is it because  
of the configuration of the proxy of the server ? or… ?

Thanks for any help.

Posted at Nginx Forum:

> **[upstream timed out](https://forum.nginx.org/read.php?2,225289,225289#msg-225289)**
>
> Hi. I'm the new admin of a website and its servers. I have a frontend nginx proxy server and an Apache backend. I sometimes have errors : 2012/04/12 17:44:33 \[error\] 13442#0: \*74193485 upstream timed out (110: Connection timed out) while reading...

---

<div class="post-metadata">

**Author:** ![OlivierC](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/4491bb/32.png) [@OlivierC](https://www.ruby-forum.com/u/OlivierC)\
**Post date:** [April 13, 2012, 11:27am UTC](https://www.ruby-forum.com/t/upstream-timed-out/218840/2 "2012-04-13T11:27:18Z")

</div>

Have you tried to increase the proxy\_connect\_timeout,  
proxy\_send\_timeout,  
proxy\_read\_timeout values? Maybe to 60 or 180 seconds?

----- Original Message -----  
From: “OlivierC” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
To: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Sent: Friday, April 13, 2012 10:59 AM  
Subject: upstream timed out

---

<div class="post-metadata">

**Author:** ![OlivierC](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/4491bb/32.png) [@OlivierC](https://www.ruby-forum.com/u/OlivierC)\
**Post date:** [April 13, 2012, 12:32pm UTC](https://www.ruby-forum.com/t/upstream-timed-out/218840/3 "2012-04-13T12:32:35Z")

</div>

Hello!

On Fri, Apr 13, 2012 at 04:59:55AM -0400, OlivierC wrote:

> “www.mysite.tld”, referrer: “[https://www.mysite.tld/another/url](https://www.mysite.tld/another/url)”  
> 2012/04/12 17:44:33 [error] 13442#0: \*74193485 no live upstreams while  
> connecting to upstream, client: 98.87.76.65, server: www.mysite.tld,  
> request: “POST /my/url HTTP/1.1”, upstream: “[http://backend/my/url](http://backend/my/url)”,  
> host: “www.mysite.tld”, referrer: “[https://www.goeland.fr/another/url](https://www.goeland.fr/another/url)”

[…]

> proxy\_read\_timeout 30;

[…]

> The problem seems to be recent and sometimes happens immediatly after  
> clients have paid through the bank online credit card form which is  
> integrated (we do not redirect to the bank website). It’s a real problem  
> for us since when it happens at that moment, clients think their order  
> and paiement have not been saved and they order a second time (and also  
> pay a second time).
> 
> I don’t really know what i’m looking for : can it be a network  
> connection problem between frontend and backend servers ? Is it because  
> of the configuration of the proxy of the server ? or… ?

How long it takes for a backend server to generate response? The  
30s read timeout might be just not enough.

Maxim D.
