# 502 errors, upstream sent too big header

**URL:** <https://www.ruby-forum.com/t/502-errors-upstream-sent-too-big-header/205347>\
**Category:** NGINX\
**Created:** [April 4, 2011, 10:52pm UTC](https://www.ruby-forum.com/t/502-errors-upstream-sent-too-big-header/205347 "2011-04-04T22:52:50Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [April 4, 2011, 10:52pm UTC](https://www.ruby-forum.com/t/502-errors-upstream-sent-too-big-header/205347/1 "2011-04-04T22:52:50Z")

</div>

We seem to be getting sporadic 502 errors, mostly when users are logging  
in.  
We run a Mediawiki based website, are running nginx 0.9.5, php-fpm  
5.3.5.

The error:

2011/04/04 10:41:34 [error] 30517#0: \*2143711 upstream sent too big  
header  
while reading response header from upstream, client: 192.168.100.5,  
server:  
\_, request: “POST  
/index.php?title=Special:Userlogin&action=submitlogin&type=login&returnto=Main-Page  
HTTP/1.1”, upstream: “fastcgi://127.0.0.1:9000”, host:  
“[www.wikihow.com](http://www.wikihow.com)”,  
referrer: “[http://www.wikihow.com/Special:Userlogin?returnto=Main-Page](http://www.wikihow.com/Special:Userlogin?returnto=Main-Page)”

Our nginx.conf proxy buffer settings:

```
proxy_buffers 16 16k;
proxy_buffer_size 32k;

```

We’ve tried increasing these values from the defaults a few times, and  
it  
doesn’t seem to fix the issue.

Do you have any suggestions on how to fix this?

Thanks,  
Travis

---

<div class="post-metadata">

**Author:** ![Travis\_Derouin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/aca169/32.png) [@Travis\_Derouin](https://www.ruby-forum.com/u/Travis_Derouin)\
**Post date:** [April 5, 2011, 6:42am UTC](https://www.ruby-forum.com/t/502-errors-upstream-sent-too-big-header/205347/2 "2011-04-05T06:42:09Z")

</div>

On Mon, Apr 04, 2011 at 04:52:22PM -0400, Travis Derouin wrote:

> referrer: “[Client Challenge](http://www.wikihow.com/Special:Userlogin?returnto=Main-Page)”
> 
> Our nginx.conf proxy buffer settings:
> 
> ```
> proxy_buffers 16 16k;
> proxy_buffer_size 32k;
> 
> ```
> 
> We’ve tried increasing these values from the defaults a few times, and it  
> doesn’t seem to fix the issue.
> 
> Do you have any suggestions on how to fix this?

```
 fastcgi_buffers 16 16k;
 fastcgi_buffer_size 32k;

```

–  
Igor S.

> **[Igor Sysoev](http://sysoev.ru/en/)**

---

<div class="post-metadata">

**Author:** ![Travis\_Derouin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/aca169/32.png) [@Travis\_Derouin](https://www.ruby-forum.com/u/Travis_Derouin)\
**Post date:** [May 2, 2011, 6:08am UTC](https://www.ruby-forum.com/t/502-errors-upstream-sent-too-big-header/205347/3 "2011-05-02T06:08:24Z")

</div>

Hi,

I’m getting this same error (please see log output below) with  
Nginx(0.8.54) and Passenger(3.0.6) using GET requests with really long  
URIs.

My assumption is that fastcgi\_buffer\* directives won’t apply to my  
configuration since the request is being handled by passenger instead of  
a php/perl fastcgi socket.

I’ve tried defining the proxy\_buffer\* settings like Travis described in  
his initial post, but that didn’t resolve the error I’m experiencing.

I’ve defined “large\_client\_header\_buffers 8 16k;” in the server  
context, but this doesn’t alleviate the error either.

Is ‘large\_client\_header\_buffers’ the proper directive I should be using?  
If not, is there a directive I can use to increase the response header  
size limit?

Thanks for any insight into this,  
Mike P.

* * *

## 2011/05/01 09:57:41 [error] 12176#0: \*4537092 upstream sent too big header while reading response header from upstream, client: x.x.x.x, server: hostname.tld, request: “GET /heroku/resources/18623?\<REALLY\_LONG\_URI\_REMOVED\> HTTP/1.1”, upstream: "passenger:unix:/

---

<div class="post-metadata">

**Author:** ![Travis\_Derouin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/aca169/32.png) [@Travis\_Derouin](https://www.ruby-forum.com/u/Travis_Derouin)\
**Post date:** [May 3, 2011, 4:03am UTC](https://www.ruby-forum.com/t/502-errors-upstream-sent-too-big-header/205347/4 "2011-05-03T04:03:29Z")

</div>

According to passenger’s documentation, it doesn’t appear that a  
directive exists to adjust any header size limitations.

Also, Phusion’s CTO doesn’t mention any possible solution here regarding  
the same error: [http://goo.gl/ZPXvO](http://goo.gl/ZPXvO)

If there is no such adjustment that can be made via passenger to  
alleviate this error, is there also no possible solution within Nginx?

Thanks!

---

<div class="post-metadata">

**Author:** ![Travis\_Derouin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/aca169/32.png) [@Travis\_Derouin](https://www.ruby-forum.com/u/Travis_Derouin)\
**Post date:** [May 3, 2011, 6:19am UTC](https://www.ruby-forum.com/t/502-errors-upstream-sent-too-big-header/205347/5 "2011-05-03T06:19:40Z")

</div>

On Mon, Apr 04, 2011 at 04:52:22PM -0400, Travis Derouin wrote:

> referrer: “[Client Challenge](http://www.wikihow.com/Special:Userlogin?returnto=Main-Page)”
> 
> Our nginx.conf proxy buffer settings:
> 
> ```
> proxy_buffers 16 16k;
> proxy_buffer_size 32k;
> 
> ```
> 
> We’ve tried increasing these values from the defaults a few times, and it  
> doesn’t seem to fix the issue.
> 
> Do you have any suggestions on how to fix this?

fastcgi\_buffers 16 16k;  
fastcgi\_buffer\_size 32k;

since you use fastcgi, but not proxy.

–  
Igor S.

---

<div class="post-metadata">

**Author:** ![Travis\_Derouin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/aca169/32.png) [@Travis\_Derouin](https://www.ruby-forum.com/u/Travis_Derouin)\
**Post date:** [May 2, 2011, 8:57pm UTC](https://www.ruby-forum.com/t/502-errors-upstream-sent-too-big-header/205347/6 "2011-05-02T20:57:16Z")

</div>

Hello!

On Mon, May 02, 2011 at 06:08:24AM +0200, Mike P. wrote:

> Hi,
> 
> I’m getting this same error (please see log output below) with  
> Nginx(0.8.54) and Passenger(3.0.6) using GET requests with really long  
> URIs.
> 
> My assumption is that fastcgi\_buffer\* directives won’t apply to my  
> configuration since the request is being handled by passenger instead of  
> a php/perl fastcgi socket.

You have to tune appropriate settings provided by passenger  
module. Please refer to passenger documentation for exact names,  
most likely passenger\_buffer\_size and so on.

[…]

Maxim D.

---

<div class="post-metadata">

**Author:** ![Travis\_Derouin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/aca169/32.png) [@Travis\_Derouin](https://www.ruby-forum.com/u/Travis_Derouin)\
**Post date:** [May 3, 2011, 11:00pm UTC](https://www.ruby-forum.com/t/502-errors-upstream-sent-too-big-header/205347/7 "2011-05-03T23:00:52Z")

</div>

Maxim,

Thanks! This makes a lot more sense now. I’ll pursue a resolution with  
passenger at this time. Hopefully this is something that they can  
eventually resolve with a future release.

Mike P.

---

<div class="post-metadata">

**Author:** ![Travis\_Derouin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/aca169/32.png) [@Travis\_Derouin](https://www.ruby-forum.com/u/Travis_Derouin)\
**Post date:** [May 3, 2011, 9:45am UTC](https://www.ruby-forum.com/t/502-errors-upstream-sent-too-big-header/205347/8 "2011-05-03T09:45:54Z")

</div>

Hello!

On Tue, May 03, 2011 at 04:03:29AM +0200, Mike P. wrote:

> According to passenger’s documentation, it doesn’t appear that a  
> directive exists to adjust any header size limitations.
> 
> Also, Phusion’s CTO doesn’t mention any possible solution here regarding  
> the same error: [http://goo.gl/ZPXvO](http://goo.gl/ZPXvO)

Ah, indeed: looking though code suggests they unconditionally set  
buffer size to pagesize and doesn’t allow it to be changed.

> If there is no such adjustment that can be made via passenger to  
> alleviate this error, is there also no possible solution within Nginx?

You may consider using another module to talk to backends,  
standard proxy or fastcgi may be a good solution.

Maxim D.

---

<div class="post-metadata">

**Author:** ![Travis\_Derouin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/aca169/32.png) [@Travis\_Derouin](https://www.ruby-forum.com/u/Travis_Derouin)\
**Post date:** [June 28, 2011, 7:19am UTC](https://www.ruby-forum.com/t/502-errors-upstream-sent-too-big-header/205347/9 "2011-06-28T07:19:52Z")

</div>

Hello!

On Mon, Jun 27, 2011 at 10:38:42PM -0400, assistlydavid wrote:

> proxy\_buffer\_size, fastcgi\_buffers, fastcgi\_busy\_buffers\_size,  
> fastcgi\_buffer\_size, large\_client\_header\_buffers.
> 
> Isn’t this error message coming from nginx, complaining about the size  
> of the header returned from passenger? Given that, surely there’s some  
> way I can tell nginx to allow a larger header size?

As it was already said in this thread, passenger module  
unconditionally set buffer size and it’s not configurable. There  
should be something like “passenger\_buffer\_size” directive, but  
it doesn’t exists.

> Any suggestions?

Either bug passenger module authors or use another module to talk  
to backends (e.g. standard fastcgi or proxy).

Maxim D.

---

<div class="post-metadata">

**Author:** ![Travis\_Derouin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/aca169/32.png) [@Travis\_Derouin](https://www.ruby-forum.com/u/Travis_Derouin)\
**Post date:** [August 4, 2011, 1:47am UTC](https://www.ruby-forum.com/t/502-errors-upstream-sent-too-big-header/205347/10 "2011-08-04T01:47:08Z")

</div>

We are having the same problem, only today 106 errors like this  
registered in our log.

If anyone has any insights about this, please post a reply, we’re  
desperate to fix this.

Posted at Nginx Forum:

> **[Re: 502 errors, upstream sent too big header](https://forum.nginx.org/read.php?2,188352,213351#msg-213351)**
>
> We seem to be getting sporadic 502 errors, mostly when users are logging in. We run a Mediawiki based website, are running nginx 0.9.5, php-fpm 5.3.5. The error: 2011/04/04 10:41:34 \[error\] 30517#0: \*2143711 upstream sent too big header while reading...

---

<div class="post-metadata">

**Author:** ![Travis\_Derouin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/aca169/32.png) [@Travis\_Derouin](https://www.ruby-forum.com/u/Travis_Derouin)\
**Post date:** [June 28, 2011, 4:39am UTC](https://www.ruby-forum.com/t/502-errors-upstream-sent-too-big-header/205347/11 "2011-06-28T04:39:28Z")

</div>

We’re having the same problem:

```
upstream sent too big header while reading response header from

```

upstream

Where:

```
upstream: "passenger:unix:/passenger_helper_server:"

```

I tried every one of proxy\_buffers, proxy\_busy\_buffers\_size,  
proxy\_buffer\_size, fastcgi\_buffers, fastcgi\_busy\_buffers\_size,  
fastcgi\_buffer\_size, large\_client\_header\_buffers.

Isn’t this error message coming from nginx, complaining about the size  
of the header returned from passenger? Given that, surely there’s some  
way I can tell nginx to allow a larger header size?

Any suggestions?

Cheers,  
David.

Posted at Nginx Forum:

> **[Re: 502 errors, upstream sent too big header](https://forum.nginx.org/read.php?2,188352,210626#msg-210626)**
>
> We seem to be getting sporadic 502 errors, mostly when users are logging in. We run a Mediawiki based website, are running nginx 0.9.5, php-fpm 5.3.5. The error: 2011/04/04 10:41:34 \[error\] 30517#0: \*2143711 upstream sent too big header while reading...

---

<div class="post-metadata">

**Author:** ![Travis\_Derouin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/aca169/32.png) [@Travis\_Derouin](https://www.ruby-forum.com/u/Travis_Derouin)\
**Post date:** [August 4, 2011, 4:02am UTC](https://www.ruby-forum.com/t/502-errors-upstream-sent-too-big-header/205347/12 "2011-08-04T04:02:22Z")

</div>

Guys did you see that Passenger 3.0.8 was released today, with this in  
the changelog:

[Nginx] Added the options passenger\_buffer\_size, passenger\_buffers and  
passenger\_busy\_buffers\_size. These options are similar to  
proxy\_module’s similarly named options. You can use these to e.g.  
increase the maximum header size limit.

Posted at Nginx Forum:

> **[Re: 502 errors, upstream sent too big header](https://forum.nginx.org/read.php?2,188352,213356#msg-213356)**
>
> We seem to be getting sporadic 502 errors, mostly when users are logging in. We run a Mediawiki based website, are running nginx 0.9.5, php-fpm 5.3.5. The error: 2011/04/04 10:41:34 \[error\] 30517#0: \*2143711 upstream sent too big header while reading...
