PHP-FPM - upstream prematurely closed connection while reading response header <p>Already saw this same question - <a href="http://stackoverflow.com/questions/14193954/upstream-prematurely-closed-connection-while-reading-response-header-from-upstre">upstream prematurely closed connection while reading response header from upstream, client</a> But as Jhilke Dai said it not solved at all and i agree. Got same exact error on nginx+phpFPM installation. Current software versions: nginx 1.2.8 php 5.4.13 (cli) on FreeBSd9.1. Actually bit isolated this error and sure it happened when trying to import large files, larger than 3 mbs to mysql via phpMyadmin. Also counted that backend closing connection when 30 secs limit reached. Nginx error log throwing this</p> <pre><code> [error] 49927#0: *196 upstream prematurely closed connection while reading response header from upstream, client: 7X.XX.X.6X, server: domain.com, request: "POST /php3/import.php HTTP/1.1", upstream: "fastcgi://unix:/tmp/php5-fpm.sock2:", host: "domain.com", referrer: "http://domain.com/phpmyadmin/db_import.php?db=testdb&amp;server=1&amp;token=9ee45779dd53c45b7300545dd3113fed" </code></pre> <p>My php.ini limits raised accordingly</p> <pre><code>upload_max_filesize = 200M default_socket_timeout = 60 max_execution_time = 600 max_input_time = 600 </code></pre> <p>my.cnf related limit</p> <pre><code>max_allowed_packet = 512M </code></pre> <p>Fastcgi limits</p> <pre><code>location ~ \.php$ { # fastcgi_split_path_info ^(.+\.php)(.*)$; fastcgi_pass unix:/tmp/php5-fpm.sock2; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_NAME $fastcgi_script_name; fastcgi_intercept_errors on; fastcgi_ignore_client_abort on; fastcgi_connect_timeout 60s; fastcgi_send_timeout 200s; fastcgi_read_timeout 200s; fastcgi_buffer_size 128k; fastcgi_buffers 8 256k; fastcgi_busy_buffers_size 256k; fastcgi_temp_file_write_size 256k; </code></pre> <p>Tried to change fastcgi timeouts as well buffer sizes, that's not helped. php error log doesn't show problem, enabled all notices, warning - nothing useful. Also tried disable APC - no effect.</p>