failed to open stream 🐘 PHP

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.

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