
When accessing a website managed through Plesk, an error message like the one above appears. This issue usually occurs randomly, or when opening certain pages on the site or when logging in.
Reason
This error occurs because the Nginx server receives a response from a backend (such as PHP-FPM) with a header
that is too large and cannot fit in the default buffer. Some common causes are:
that is too large and cannot fit in the default buffer. Some common causes are:
- Too many cookies from the browser
- The header is too long (e.g., due to too many plugins, redirects, or rewrites)
- The Nginx buffer setting is too small
- The PHP handler is not compatible with the Nginx configuration.
Solution
1. Log in to Plesk Panel
Access your Plesk panel using the admin account.
2. Check the PHP Handler in Use
Navigate to: Domains > [yourdomainname.com] > PHP Settings
In the Run PHP as section, note the PHP handler being used. Examples include:
FPM served by nginx
FastCGI
CGI, etc.
3. Add nginx Directives
Go to: Domains > [yourdomainname.com] > Apache & nginx Settings
Scroll down to the Additional nginx directives section and follow the appropriate steps:
If the PHP handler is "FPM served by nginx" and Proxy Mode is disabled: Add the following directives:
fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;
proxy_buffers 8 16k;
proxy_buffer_size 32k;
Additional Notes :
1. After making changes, clear your browser cache and reload the website.
2. If you're using Cloudflare or another CDN, ensure there are no header/cookie conflicts. These issues are usually technical and not directly related to the website content.
1. After making changes, clear your browser cache and reload the website.
2. If you're using Cloudflare or another CDN, ensure there are no header/cookie conflicts. These issues are usually technical and not directly related to the website content.
Conclusion The 502 Bad Gateway: upstream sent too large header error in Plesk is generally caused by an insufficiently large nginx buffer configuration. By adjusting the nginx directives according to the PHP handler, this error can be quickly resolved.