fastcgi nginx nginx-reverse-proxy php wordpress

upstream sent too big header while reading response header from upstream


I am getting these kind of errors:

2014/05/24 11:49:06 [error] 8376#0: *54031 upstream sent too big header while reading response header from upstream, client:, server:, request: “GET /the-brainwash-chronicles-sponsored-by-gujarat-government/,%20https:/,%20https:/,%20https:/,%20https:/,%20https:/,%20https:/,%20https:/,%20https:/,%20https:/,%20https:/,%20https:/,%20https:/,%20https:/,%20https:/,%20https:/,%20,%20https:/,%20https:/,%20https:/,%20https:/,%20https:/,%20https:/,%20ht

Always it is the same. A url repeated over and over with comma separating. Can’t figure out what is causing this. Anyone have an idea?

Update: Another error:

http request count is zero while sending response to client

Here is the config. There are other irrelevant things, but this part was added/edited

fastcgi_cache_path /var/nginx-cache levels=1:2 keys_zone=WORDPRESS:100m inactive=60m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
fastcgi_cache_use_stale error timeout invalid_header http_500;
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
proxy_buffer_size   128k;
proxy_buffers   4 256k;
proxy_busy_buffers_size   256k;
    # Upstream to abstract backend connection(s) for PHP.
    upstream php {
            #this should match value of "listen" directive in php-fpm pool
            server unix:/var/run/php5-fpm.sock;

And then in the server block:
set $skip_cache 0;

    # POST requests and urls with a query string should always go to PHP
    if ($request_method = POST) {
            set $skip_cache 1;
    if ($query_string != "") {
            set $skip_cache 1;

    # Don't cache uris containing the following segments
    if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|index.php|sitemap(_index)?.xml") {
            set $skip_cache 1;

    # Don't use the cache for logged in users or recent commenters
    if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
            set $skip_cache 1;

    location / {
            # This is cool because no php is touched for static content.
            # include the "?$args" part so non-default permalinks doesn't break when using query string
            try_files $uri $uri/ /index.php?$args;

    location ~ \.php$ {
            try_files $uri /index.php;
            include fastcgi_params;
            fastcgi_pass php;
            fastcgi_read_timeout 3000;

            fastcgi_cache_bypass $skip_cache;
            fastcgi_no_cache $skip_cache;

            fastcgi_cache WORDPRESS;
            fastcgi_cache_valid  60m;

    location ~ /purge(/.*) {
        fastcgi_cache_purge WORDPRESS "$scheme$request_method$host$1";


  • your proxy config does not seem right. Can you share the config?

    – Neo

    May 24, 2014 at 12:06

  • can you try adding: fastcgi_buffers 16 16k; fastcgi_buffer_size 32k;

    – Neo

    May 24, 2014 at 13:07

  • 2

    possible duplicate of Upstream too big – nginx + codeigniter

    – dnozay

    Mar 18, 2015 at 19:17


Add the following to your conf file

fastcgi_buffers 16 16k; 
fastcgi_buffer_size 32k;


  • 188

    While your answer led me to the correct response, you should show how to determine the correct buffer sizes and why that matters. Otherwise it’s a shot in the dark. See here for getting an idea on sizing:…

    Sep 9, 2014 at 15:37

  • 6

    “fastcgi_buffer_size 32k;” alone did not work, I needed both lines for NginX to restart. I came here because of a 502 error with NginX caused by a WordPress plugin.

    – PJ Brunet

    Apr 19, 2016 at 21:20

  • 8

    If fast_cgi_buffers don’t help, try the proxy_buffers answer below by @amd

    – icc97

    Mar 29, 2017 at 12:13

  • 20

    Any explanation on this answer please.

    May 17, 2017 at 18:28

  • 11

    Its works for me, I just want to add that in ubuntu 16.04 the nginx configuration file is located at /etc/nginx/nginx.conf and the values should go inside http {…}

    – Mario

    Feb 26, 2018 at 17:20


If nginx is running as a proxy / reverse proxy

that is, for users of ngx_http_proxy_module

In addition to fastcgi, the proxy module also saves the request header in a temporary buffer.

So you may need also to increase the proxy_buffer_size and the proxy_buffers, or disable it totally (Please read the nginx documentation).

Example of proxy buffering configuration

http {
  proxy_buffer_size   128k;
  proxy_buffers   4 256k;
  proxy_busy_buffers_size   256k;

Example of disabling your proxy buffer (recommended for long polling servers)

http {
  proxy_buffering off;

For more information: Nginx proxy module documentation


  • 11

    “proxy_busy_buffers_size” must be less than the size of all “proxy_buffers” minus one buffer

    – chovy

    Mar 30, 2015 at 4:30

  • you are the man! thanks! first option worked in my ruby on rails app

    – Nezir

    May 27, 2019 at 16:38

  • Probably a silly question, but I have a proxy in front of the server that is returning this error. Changing the buffer worked, but I get a new error on the inside machine. writev() failed (104: Connection reset by peer) while sending to client Would those proxy settings possibly fix that error, and would hey go on the upstream server or the proxy?

    Aug 15, 2019 at 2:35

  • 2

    Why the proxy_buffers 4 ... ? Since default seems to be 8

    – adrianTNT

    Jan 30, 2020 at 2:47

  • 1

    For me, setting buffers was still necessary despite setting buffering off…

    – Luc

    Dec 6, 2020 at 18:57


Plesk instructions

I combined the top two answers here

In Plesk 12, I had nginx running as a reverse proxy (which I think is the default). So the current top answer doesn’t work as nginx is also being run as a proxy.

I went to Subscriptions | [subscription domain] | Websites & Domains (tab) | [Virtual Host domain] | Web Server Settings.

Then at the bottom of that page you can set the Additional nginx directives which I set to be a combination of the top two answers here:

fastcgi_buffers         16  16k;
fastcgi_buffer_size         32k;
proxy_buffer_size          128k;
proxy_buffers            4 256k;
proxy_busy_buffers_size    256k;


  • 1

    Where? Which config?

    – Redsandro

    Nov 13, 2017 at 11:12

  • @Redsandro If you can’t find it via Subscriptions | [subscription domain] | Websites & Domains (tab) | [Virtual Host domain] | Web Server Settings then I’m not sure what you mean?

    – icc97

    Nov 13, 2017 at 12:00

  • 1

    this was the solution for me: Domains > Domain name > Apache & nginx Settings > Additional nginx directives Plesk Onyx Version 17.8.11

    – user74847

    Feb 26, 2019 at 16:07

  • 2

    I added this in a new file /etc/nginx/conf.d/proxy.conf and restarted nginx, it works fine, thanks!

    – rubo77

    Jul 10, 2019 at 12:40