Im having some server issues with large uploads on channel images. I have some users who have as many as 150 images and when they try and edit their profile they are getting 502 errors

looking at the logs Im getting this error

2015/01/28 19:26:52 [error] 2880#0: *14 recv() failed (104: Connection reset by peer) while reading response header from upstream, client:, server: www.visualaids.org, request: "POST /liza/index.php?/cp/content_publish/entry_form&channel_id=9&entry_id=6475&filter=YTozOntzOjEwOiJjaGFubmVsX2lkIjtzOjE6IjkiO3M6ODoia2V5d29yZHMiO3M6MTY6Ikpvc2UgTHVpcyBDb3J0ZXMiO3M6OToic2VhcmNoX2luIjtzOjU6InRpdGxlIjt9 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "www.visualaids.org", referrer: "https://www.visualaids.org/liza/index.php?S=0&D=cp&C=content_publish&M=entry_form&channel_id=9&entry_id=6475&&filter=YTozOntzOjEwOiJjaGFubmVsX2lkIjtzOjE6IjkiO3M6ODoia2V5d29yZHMiO3M6MTY6Ikpvc2UgTHVpcyBDb3J0ZXMiO3M6OToic2VhcmNoX2luIjtzOjU6InRpdGxlIjt9"

There was more specific errors about exceeding max_input_vars and i raised that in the php.ini but still no dice.

I also adjusted nginx settings for

fastcgi_read_timeout 300; fastcgi_buffer_size 1024k; fastcgi_buffers 4 1024k; fastcgi_busy_buffers_size 1024k;

and still no luck? anything else I should try?

  • do you have any errors in php-fpm logs?
    – Max Lazar
    Commented Jan 29, 2015 at 2:19

2 Answers 2


Try next settings for nginx:

client_max_body_size 10m;
client_body_buffer_size 128k;
fastcgi_connect_timeout 90;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 1024K;
fastcgi_buffers 8 512k;
fastcgi_busy_buffers_size 1024k;
fastcgi_temp_file_write_size 1024k;

It can be also error with php - not enough child processes. Check logs and try to increase it in php-fpm settings:

pm = static
pm.max_children = 60

if it's helps - you need to play with pm.max_children \ pm.max_spare_servers to make it work for pm = dynamic.

p.s. and (just for sure) don't forget to restart nginx/php-fpm after changes

  • still fails.. is there anything else i can/should try? Commented Feb 11, 2015 at 21:30

I had a similar problem with 502 Bad Gateways, but in my case it was for AJAX requests. The following nginx directives worked for me;

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.