failed to open stream PHP Origin: Application & API OSI layer 7 · Application Last updated 12 Oct 2026

Warning: include(x.php): Failed to open stream: No such file or directory

PHP couldn’t open a file for include/require/fopen — wrong path, missing file, or no permission.

Exact message you may see Failed to open streamfailed opening requiredNo such file or directory
Seen on: PHP

Meaning

Relative paths are resolved from the current working directory and include_path, not from the file that does the include. Using __DIR__ makes paths reliable. “Permission denied” instead of “No such file” means the web server user can’t read it.

Common causes

  • Relative path resolved from a different working directory
  • File missing on the server (not uploaded, case mismatch)
  • Web server user lacks read permission
  • open_basedir restriction

⚡ Quick fix

  1. Build paths with __DIR__ . '/file.php'
  2. Check the exact path and file name case
  3. Fix permissions (644 files, 755 dirs)
  4. Check open_basedir in php.ini

Detailed fix by platform

PHP

  1. require_once __DIR__ . '/../includes/config.php';

How to diagnose

  1. Path — Exact path in the message — does it exist?
  2. Case — Linux is case-sensitive
  3. Permissions — Readable by the web server user?

🔧 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):

0x80070020 — 0x80070020: The process cannot access the file because it is being used by another process (Windows)0x800700200x80070570 — Error 0x80070570: The file or directory is corrupted and unreadable (Windows)0x80070570Access to the path is denied — System.UnauthorizedAccessException: Access to the path 'x' is denied (.NET)Access to the path is…AccessDeniedException — java.nio.file.AccessDeniedException: /path (Java)AccessDeniedExceptionArgument list too long — bash: /bin/rm: Argument list too long (Linux)Argument list too longCannot redeclare — Fatal error: Cannot redeclare function foo() (previously declared in …) (PHP)Cannot redeclareEACCES — Linux: Permission denied (Linux)EACCESENOENT — Error: ENOENT: no such file or directory (Node.js)ENOENTfailed to…

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.