How to Debug "Fastcgi Sent in Stderr: Primary Script Unknown While Reading Response Header from Upstream" and Find the Actual Error Message

How to debug FastCGI sent in stderr: Primary script unknown while reading response header from upstream and find the actual error message?

To answer your question:

  1. in php-fpm.d/www.conf file:

set the access.log entry:

access.log = /var/log/$pool.access.log

  1. restart php-fpm service.

  2. try to access your page

  3. cat /var/log/www.access.log, you will see access logs like:

- - 10/Nov/2016:19:02:11 +0000 "GET /app.php" 404
- - 10/Nov/2016:19:02:37 +0000 "GET /app.php" 404

To resolve "Primary script unknown" problem:

  • if you see "GET /" without a correct php file name, then it's your nginx conf problem.

  • if you see "GET /app.php" with 404, it means nginx is correctly passing the script file name but php-fpm failed to access this file (user "php-fpm:php-fpm" don't have access to your file, which trapped me for 3 hours)

Hope my answer helps.

error 28105#0: *1 FastCGI sent in stderr: Primary script unknown while reading response header from upstream

Also, need to share files to the php:fpm docker container too. The answer is to run docker php:fpm image with volume too:

docker run -it -p 127.168.66.66:9000:9000 -v /var/www/html/:/var/www/html/ php:fpm

1 FastCGI sent in stderr: Primary script unknown

Ok, so 3 things I found after a day of struggling

  1. For some reason I had already something running on port 9000 so I
    changed to 9001
  2. My default site was intercepting my new one, once again I don't
    under stand why since it shouldn't, but I just unlinked it
  3. Nginx doesn't automatically do the sym link for sites-available to
    site-enabled.

Hope this saves someone some trouble!

Here is a more detailed link in server fault: https://serverfault.com/questions/517190/nginx-1-fastcgi-sent-in-stderr-primary-script-unknown/517207#517207



Related Topics



Leave a reply



Submit