title: How To Troubleshoot "FastCGI: incomplete headers (0 bytes) received from server" error
body: <p>I keep receiving the following error:</p>
  
  <pre><code>Wed Mar 30 01:22:43.780576 2016] [fastcgi:error] [pid 12345:tid 1234567890] [client 123.459.78.123:12345] FastCGI: incomplete headers (0 bytes) received from server "/path/to/php5-fcgi", referer: http://example.com/some/file.php
  </code></pre>
  
  <p>Which only occurs when i visit a specific page (controllers). What confuses me even more, this error appears to be in random. Meaning that sometime i can access the page just fine, other times i keep getting that error.</p>
  
  <p>The page i am talking about is the backoffice of Prestashop 1.5.4, specifically the order page (Backoffice > Orders > Order).</p>
  
  <p>That page does send a query to MySQL (how ever it took less than a sec). Here's the full query (debugged):</p>
  
  <pre><code>SELECT SQL_CALC_FOUND_ROWS
  a.`id_order`,`reference`,`total_paid_tax_incl`,`payment`,a.date_add as date_add, 
  a.id_currency,
  a.id_order AS id_pdf,
  CONCAT(LEFT(c.`firstname`, 1), '. ', c.`lastname`) AS `customer`,
  osl.`name` AS `osname`,
  os.`color`,
  IF((SELECT COUNT(so.id_order) FROM `ps_orders` so WHERE so.id_customer = a.id_customer) &gt; 1, 0, 1) as new
  FROM `ps_orders` a
  LEFT JOIN `ps_customer` c ON (c.`id_customer` = a.`id_customer`)
  LEFT JOIN `ps_order_state` os ON (os.`id_order_state` = a.`current_state`)
  LEFT JOIN `ps_order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = 1) 
  WHERE 1 
  ORDER BY a.id_order DESC LIMIT 0,50;
  </code></pre>
  
  <p>My biggest suspicious is that there is something wrong with the query, because when i ran that query using MySQL Workbench, the initial run took about 2 secs. When i ran the query again (immediately after the first one) it took ~0.059 (could be cache).</p>
  
  <p>Can anyone help me with this?</p>
  
  <p>I am using Ubuntu 14.04
  PHP 5.5.9
  Apache 2.4.7 (with PHP5-FPM)</p>
  
  <p>** EDIT **</p>
  
  <p>When i ran:</p>
  
  <pre><code>sudo tail -f /var/log/upstart/php5-fpm.log
  </code></pre>
  
  <p>This is what i get:</p>
  
  <pre><code>[04-Apr-2016 10:55:54] WARNING: [pool www] child 37686 exited on signal 11 (SIGSEGV - core dumped) after 111.726966 seconds from start
  [04-Apr-2016 10:55:54] NOTICE: [pool www] child 38128 started
  [04-Apr-2016 10:55:54] WARNING: [pool www] child 37774 exited on signal 11 (SIGSEGV - core dumped) after 81.831809 seconds from start
  [04-Apr-2016 10:55:54] NOTICE: [pool www] child 38129 started
  [04-Apr-2016 10:55:54] WARNING: [pool www] child 37798 exited on signal 11 (SIGSEGV - core dumped) after 76.299913 seconds from start
  [04-Apr-2016 10:55:54] NOTICE: [pool www] child 38130 started
  [04-Apr-2016 10:55:54] WARNING: [pool www] child 37768 exited on signal 11 (SIGSEGV - core dumped) after 83.162501 seconds from start
  [04-Apr-2016 10:55:54] NOTICE: [pool www] child 38131 started
  [04-Apr-2016 10:55:57] WARNING: [pool www] child 37859 exited on signal 11 (SIGSEGV - core dumped) after 65.427848 seconds from start
  [04-Apr-2016 10:55:57] NOTICE: [pool www] child 38133 started
  </code></pre>
  
  <p>There is now new warning/notice/error that show up when i execute the problematic page.</p>
  
  <p>** EDIT 2 **
  I think i narrow down the problem after turning on slow_log on my fpm config. This is what i get:</p>
  
  <pre><code>script_filename = /path/to/some/script.php
  [0x00007f55bb18afd8] query() /path/to/some/script/DbPDO.php:80
  [0x00007f55bb18aef8] _query() /path/to/some/script/Db.php:305
  [0x00007f55bb18ad88] query() /path/to/some/script/Db.php:482
  [0x00007f55bb18ab68] executeS() /path/to/some/script/AdminController.php:2198
  [0x00007f55bb18a9e8] getList() /path/to/some/script/AdminController.php:1531
  [0x00007f55bb18a8d0] renderList() /path/to/some/script/AdminController.php:1440
  [0x00007f55bb18a788] initContent() /path/to/some/script/Controller.php:167
  [0x00007f55bb18a5d0] run() /path/to/some/script/Dispatcher.php:349
  [0x00007f55bb18a480] dispatch() /path/to/some/script/index.php:50
  </code></pre>
  
  <p>More best guess would be because of this function :</p>
  
  <pre><code>[0x00007f55bb18ab68] executeS() /path/to/some/script/AdminController.php:2198
  </code></pre>
  
  <p>Where it basically send a query i mentioned earlier. Changing this would mean i have to change the core engine of Prestashop. I do not wish to do that, since it may have some dependencies to other functions/modules.</p>
  
  <p>I wonder if there is a way where i can slightly increase the timeout on my php-fpm or Apache. I know such solution exist, i just don't know where to look/begin.</p>