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.
Primary script unknownFile not found. 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 not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
Most viewed in PHP
Other ways to find it
Where this error sits
Origin: Application & API. Errors that are often confused with or caused by this one (click to open):
🧠 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.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 14 Oct 2026