October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
VGSources
Blog

Fix the “Access to the Script Denied” FastCGI Error in Nginx

A practical guide to PHP-FPM’s “Access to the script has been denied” message in Nginx, including security.limit_extensions, empty script paths, try_files routing, validation, and safer fixes.
WorldNginx Length8 min Posted Quest giverVGSources Team

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The message Access to the script '...' has been denied (see security.limit_extensions) is produced by PHP-FPM, even though you usually notice it while troubleshooting an Nginx request. PHP-FPM is refusing to execute the requested primary script because its filename extension is not in the pool’s security.limit_extensions allow-list. Add only the extension you deliberately need, verify that Nginx passes the correct script path, test the configuration, and reload PHP-FPM.

If the log instead says Access to the script '' has been denied, start with the path and FastCGI-parameter checks: PHP-FPM is receiving an empty or malformed script name rather than simply rejecting a disallowed extension.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What this FastCGI error actually means

PHP-FPM checks the filename of the primary script before executing it. Its pool-level security.limit_extensions directive contains the extensions PHP-FPM is willing to run. The PHP manual lists the default as .php .phar; older documentation described only .php, and the default changed to include .phar in the PHP 5.3.9/5.4.0RC2 timeframe.

When Nginx forwards a request whose target ends in an extension outside that list, PHP-FPM writes an access-denied message to its log. A request for an HTML or XML file can therefore trigger the same wording if your Nginx rules route that file to PHP-FPM. The denial is an execution safeguard, not proof that the file is missing or that Nginx’s filesystem permissions are wrong.

The exact wording matters:

  • A path appears between the quotes: inspect the extension in that path and the pool’s security.limit_extensions value.
  • The quotes are empty: investigate how Nginx constructs and sends the script path, especially SCRIPT_FILENAME, PATH_TRANSLATED, PATH_INFO, and named-location routing.

Fastest safe fix when an extension is intentionally executable

Only change the pool that serves the affected site, and keep the allow-list as narrow as possible. The PHP manual’s security guidance is to restrict execution to .php whenever that meets your application’s needs.

  1. Read the log entry. Copy the complete path shown after Access to the script. Its suffix is the extension PHP-FPM evaluated.
  2. Locate the active PHP-FPM pool file. It is commonly named www.conf inside a distribution-specific pool.d directory, but the directory and PHP version are installation-dependent. Make sure you edit the pool referenced by the Nginx site, not an unused pool for another PHP version.
  3. Inspect or set the directive. In the pool file, use one space-separated list, for example:
    security.limit_extensions = .php .phar .xml

    Replace .xml with the extension your application genuinely needs. Do not copy this example unchanged if XML, HTML, or another format should remain non-executable.

  4. Save the file and reload PHP-FPM. Pool changes are read by PHP-FPM, so reload or restart the PHP-FPM service using the service name supplied by your operating system. A web-server reload alone does not apply a changed pool directive.
  5. Reproduce one request and read the log again. A successful request should no longer generate the extension-denied message. If it still does, confirm that the request reaches the pool you edited and that the extension is spelled exactly as PHP-FPM receives it, including the leading dot.

Adding an extension permits PHP-FPM to treat files with that suffix as primary PHP scripts. It does not convert the file’s contents into valid PHP, and it broadens the set of files an attacker could attempt to execute if another vulnerability lets them place or modify files. For that reason, do not solve a routine PHP request by allowing every extension.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Check the Nginx FastCGI hand-off before changing the allow-list

If the denied path is unexpected, or if the message contains an empty script name, verify the variables Nginx sends to PHP-FPM. The key value is SCRIPT_FILENAME: it must resolve to the real file on disk that PHP-FPM should execute. A common pattern is:

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

The correct expression depends on your document-root and URI design. What matters is that the resulting filesystem path is neither empty nor a URI, and that it points to the intended file. Compare the path in the PHP-FPM log with the actual file location and with the root (or equivalent document-root setting) in the Nginx server block.

Confirm the PHP location block

In the Nginx server configuration, inspect the location that passes requests to PHP-FPM. Confirm that it:

  • matches the PHP requests your application actually generates;
  • passes the expected FastCGI parameter file or explicit parameters;
  • sets SCRIPT_FILENAME to a real filesystem path; and
  • uses the socket or TCP endpoint belonging to the intended PHP-FPM pool.

After any Nginx edit, run:

nginx -t

Proceed with an Nginx reload only when the test reports a valid configuration. This catches syntax errors, missing include files, and other mistakes before they replace a working configuration.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Remove path parameters that produce an empty script name

A documented variant of this error is Access to the script '' has been denied. Sources associate that form with the script path not being passed through correctly. If your configuration explicitly sends PATH_TRANSLATED or PATH_INFO, temporarily remove those parameters and retest. Keep only the parameters your application needs; an incorrect path parameter can cause PHP-FPM to evaluate an empty script name even when the requested URL looks valid.

Do not treat removal as a universal recipe. First compare the variables sent by your location block with the path shown in the PHP-FPM log and with the application’s URL scheme. The objective is a correct, non-empty SCRIPT_FILENAME, not simply fewer parameters.

Routing patterns that commonly trigger the denial

try_files fallback into a named location

Routing can make a normal-looking PHP URL arrive at PHP-FPM with the wrong script information. One reported cause was a try_files fallback into a named location. Switching to a plain regular-expression PHP location resolved that case because the request was handled by the expected PHP block instead of a named fallback with different FastCGI variables.

Review every internal redirect in the request path. Trace where try_files sends a miss, then check which location ultimately sets SCRIPT_FILENAME. If the final location does not set it correctly, PHP-FPM may receive an empty value or a path that does not match the requested script.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Non-PHP URLs routed to PHP-FPM

If the logged path ends in .html, .xml, or another non-PHP suffix, determine why that URL is being sent to PHP-FPM. It may be intentional—for example, an application that uses a nonstandard extension for executable templates—or it may be an overly broad Nginx location. The safer correction is usually to route static files as static files or narrow the PHP location, rather than adding a broad extension to security.limit_extensions.

Choosing the right correction

What you observe Most likely check Preferred action
The log shows a real path ending in an extension your application intentionally executes. The active pool’s security.limit_extensions. Add that one extension, retain .php, reload PHP-FPM, and retest.
The log shows a real path with an unexpected extension. Nginx location matching and internal redirects. Correct routing so only intended scripts reach PHP-FPM; do not expand the allow-list merely to hide the symptom.
The log says Access to the script '' has been denied. SCRIPT_FILENAME, PATH_TRANSLATED, PATH_INFO, and named-location routing. Make the script path non-empty and filesystem-based, then retest.
The value appears correct, but the error persists. Which pool and PHP-FPM endpoint serve the request. Verify the Nginx socket or port and edit that pool’s configuration, then reload the matching PHP-FPM service.

Security implications of the available workarounds

Keep the extension list narrow

security.limit_extensions is an execution boundary. The PHP manual recommends limiting it to .php where possible because allowing additional suffixes increases the number of filenames PHP-FPM will attempt to execute. If a feature requires another suffix, allow only that suffix and document why it is needed.

Do not enable cgi.fix_pathinfo as a reflex

Some troubleshooting posts suggest setting cgi.fix_pathinfo to 1. The cited discussions warn that this can open security holes. It is not a general fix for an incorrect Nginx-to-PHP path. Correct the location matching and FastCGI parameters instead, and assess any legacy application requirement separately.

Be skeptical of disabling the check

A community bug comment mentions setting security.limit_extensions to FALSE to bypass the restriction. That is not the PHP manual’s recommended configuration and is broader than allowing a specific required suffix. Treat it as an unsafe last-resort experiment, not a production solution; verify behavior against the PHP version’s current documentation before considering it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Permissions: what to verify, and what this error does not prove

PHP-FPM’s worker user and group still need read access to the target file and traversal access to its parent directories. Check those permissions if the path and extension are correct but execution fails in a different way. However, the cited causes for this exact “see security.limit_extensions” message concern the extension rule and script-path construction; permissions were not established as the root cause by those sources.

SELinux was not identified in the cited material as a cause of this specific message. Do not label SELinux the cause without separate evidence from your system’s audit logs and policy diagnostics.

A complete validation sequence

  1. Capture the exact error. Note whether the quoted script path is populated and record its extension.
  2. Identify the serving pool. Follow the Nginx FastCGI socket or TCP endpoint to the PHP-FPM pool and PHP version that actually handle the request.
  3. Compare the extension. Read security.limit_extensions in that pool. Remember that the documented default is .php .phar, not an unrestricted list.
  4. Inspect the generated path. Ensure SCRIPT_FILENAME resolves to the intended file under the configured document root. Check for an empty value, a URI instead of a filesystem path, or a path produced by the wrong internal redirect.
  5. Review path-related parameters. If the script name is empty or inconsistent, examine PATH_TRANSLATED and PATH_INFO and remove incorrect explicit settings.
  6. Check routing. Trace try_files fallbacks and named locations. Make sure the final PHP location supplies the same correct FastCGI parameters as the direct PHP path.
  7. Test before reloading Nginx. Run nginx -t; fix any reported error before reloading.
  8. Reload PHP-FPM after pool edits. Then send one request and inspect the logs again.
  9. Check file access only after the above. Confirm the PHP-FPM worker can read the file and traverse its directories if the extension and path now pass validation.

Common mistakes and their safer alternatives

  • Editing the wrong configuration file: a server may have multiple PHP versions or pools. Follow the endpoint used by Nginx and edit that pool.
  • Reloading only Nginx: pool directives are read by PHP-FPM. Reload the PHP-FPM service after changing www.conf or its equivalent.
  • Allowing every suffix: this removes the protection that the directive provides. Add one justified extension instead.
  • Changing cgi.fix_pathinfo without understanding the path: this can create a security exposure while leaving the routing error intact.
  • Assuming every denial is a permission problem: the “see security.limit_extensions” wording specifically points first to PHP-FPM’s extension check.
  • Skipping syntax validation: always run nginx -t before a reload after editing Nginx configuration.

When the error is resolved

A successful correction has two parts: PHP-FPM receives a non-empty SCRIPT_FILENAME that points to the intended file, and that file’s extension is explicitly allowed by the serving pool. The narrowest configuration that meets both conditions is the safest one. Leave unrelated files routed as static content, retain the default restriction when you can, and keep the log entry from the first successful retest so future configuration changes can be compared against a known-good request.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.