FastCGI sent in stderr: "Primary script unknown"
Nginx passed a script path to PHP-FPM that PHP-FPM couldn’t find — usually a wrong SCRIPT_FILENAME or root.
Seen on:
PHP
Meaning
Nginx builds SCRIPT_FILENAME from $document_root$fastcgi_script_name. If root is wrong, the file doesn’t exist, or PHP-FPM runs in a different filesystem (container), FPM answers “Primary script unknown” and the browser shows “File not found.”
Common causes
- Missing/incorrect
fastcgi_param SCRIPT_FILENAME - Nginx root differs from where the files are
- PHP-FPM in a container with a different path
- open_basedir/chroot restrictions
⚡ Quick fix
- Add
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - Make root match the real path in both Nginx and PHP-FPM
- Mount the same path in both containers
Detailed fix by platform
Nginx
include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
How to diagnose
- Path — What SCRIPT_FILENAME does Nginx send?
- FPM view — Does that path exist inside FPM?
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026