title: How to debug "FastCGI sent in stderr: Primary script unknown while reading response header from upstream" and find the actual error message?
body: <p>SO has many articles mentioning this error code:</p>
  
  <pre><code>FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream...
  </code></pre>
  
  <p>That probably means that this error message is more or less useless.  </p>
  
  <p>The message is telling us that the FastCGI handler doesn't like whatever it was sent for some reason.  The problem is that sometimes we have no idea what the reason is.</p>
  
  <p>So I'm re-stating the question -- How do we <strong><em>debug</em></strong> this error code?</p>
  
  <p>Consider the situation where we have a very simple site, with just the phpinfo.php file.  Additionally, there is a very simple nginx config, as follows:</p>
  
  <pre><code>server {
      server_name testsite.local;
  
      root /var/local/mysite/;
  
      location / {
          index index.html index.htm index.php;
      }
  
      location ~ \.php$ {
          include /etc/nginx/fastcgi_params;
          fastcgi_pass  fastcgi_backend;
          fastcgi_index index.php;
          fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      }
  }
  </code></pre>
  
  <p><strong>How can we see output/log exactly what fastcgi_params got sent to the script?</strong></p>
  
  <p><strong>How can we see the actual error message?</strong>  In my case, I'm using php-fpm.  It has no info in the log about this error.  The logs do not append any rows for this error.  Is there a verbose mode for php-fpm?</p>
  
  <pre><code>/var/log/php-fpm/error.log
  /var/log/php-fpm/www-error.log
  </code></pre>
  
  <p>I've tried to set this in the php-fpm.conf file</p>
  
  <pre><code>log_level = notice
  </code></pre>
  
  <p>and this in the php-fpm.d/www.conf file:</p>
  
  <pre><code>catch_workers_output = yes
  </code></pre>