Websites hosted on Plesk server are unavailable with 502 Bad Gateway: upstream sent too big header while reading response header

Symptoms

  • Website or website preview is unavailable:

    PLESK_INFO: 502 Bad Gateway

  • In the log files /var/log/nginx/error.log or /var/www/vhosts/example.com/logs/proxy_error_log, the following error messages can be found:

 

[error] 14790#0: *188 upstream sent too big header while reading response header from upstream, client: 203.0.113.2, server: subdomain.example.com, request: "POST /admin_catalog.php HTTP/1.1", upstream: "http://10.0.0.1:7080/admin_catalog.php", host: "subdomain.example.com", referrer: "http://subdomain.example.com/admin_catalog.php"
[error] 707#0: *2016153 FastCGI sent in stderr: "PHP message: Error checking in buffer: The buffer you checked in was not checked out" while reading upstream, client: 203.0.113.2, server: example.com, request: "POST /wp-admin/admin-ajax.php HTTP/1.1", upstream: "fastcgi://unix:///var/www/vhosts/system/example.com/php-fpm.sock:", host:"example.com", referrer: "https://example.com/wp-admin/post-new.php?wp-post-new-reload=true"
2020/04/27 20:07:05 [error] 4966#0: *39052 proxy_buffer_size x is not enough for cache key, it should be increased to at least xx, client: *****, server: example.com, request: "GET /wp-admin/admin-post.php.."

 

  • The same symptoms can be observed when WHMCS is installed on the same server as Plesk and when navigating to WHMCS > Clientes > John Doe > Invoices.

Cause

A request cannot be processed by the proxy server because of insufficient buffer size.

Resolution

For one or few domains

Log into Plesk.

Go to Domains > example.com > PHP Settings and check the selected PHP handler (the field run PHP as).

Go to Domains > example.com > Apache & nginx Settings, scroll down to the field Additional nginx directives and set the following parameters in accordance with the used PHP handler:

For PHP handler FPM application served by Nginx and disabled Proxy Mode:

fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;
For other cases:

proxy_buffers 8 16k;
proxy_buffer_size 32k;


Increase values of these parameters if it is needed.

For all domains

  1. Connect to the server using SSH.

  2. Open the file /etc/nginx/nginx.conf for editing.

  3. Increase the following parameters in the section http {:

    proxy_buffers 8 16k;
    proxy_buffer_size 32k;
    fastcgi_buffers 8 16k;
    fastcgi_buffer_size 32k;
  4. Restart nginx to apply changes:

    # service nginx restart

Increase values of these parameters if it is needed.

 

 

 

 

 

 

 

 

 

 

 

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to Install Plesk Control Panel on Linux

how to install Plesk Control Panel in simple manner without any headache.Step 1: Getting OS Name...

Enable compression for default on my all domains on plesk - Nginx ?

Plesk Panel 11 Linux introduces Nginx heres what Plesk details about the Nginx component. [+]...

Compressing all web pages with mod_deflate - Apache

Overview The mod_deflate module allows the Apache2 web service to compress files and deliver...