Primary script unknown PHP Origin: Application & API Last updated 14 Oct 2026

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.

Exact message you may see Primary script unknownFile not found.
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

  1. Add fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  2. Make root match the real path in both Nginx and PHP-FPM
  3. Mount the same path in both containers

Detailed fix by platform

Nginx

  1. include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

How to diagnose

  1. Path — What SCRIPT_FILENAME does Nginx send?
  2. 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:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

403 — HTTP 403 Forbidden (HTTP)403403 Forbidden wp-admin — WordPress: 403 Forbidden on wp-admin, wp-login.php or admin-ajax.php (WordPress)403 Forbidden wp-admin404 — HTTP 404 Not Found (HTTP)404404 except homepage — WordPress: 404 Not Found on every page except the homepage (permalinks / .htaccess / Nginx rules) (WordPress)404 except homepage444 — Nginx 444 No Response (connection closed without response) (HTTP)444495 — Nginx 400: The SSL certificate error (495 / 496 client certificate) (HTTP)495497 — 400 Bad Request: The plain HTTP request was sent to HTTPS port (Nginx 497) (HTTP)497502 — HTTP 502 Bad Gateway (HTTP)502Primary s…

Explore the map of this error Full error map →

🧠 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.