Failed to Open Stream in WordPress: How to Fix It Fast

Failed to open stream in WordPress means PHP tried to include, require, or read a file and could not. The text after the phrase tells you why: No such file or directory means the file is missing or the path is wrong, and Permission denied or Operation not permitted means ownership, permissions, or a server restriction such as open_basedir. Start from the exact file path in the error.

Quick checks

  • Copy the full error line and note the file path, the function, and the reason after “Failed to open stream”.
  • Check whether that file exists: ls -l /full/path/from/error.php.
  • If you only see a blank page or “critical error”, enable WP_DEBUG_LOG and read wp-content/debug.log.
  • If the path is inside wp-content/plugins/ or wp-content/themes/, disable or reinstall that plugin or theme first.
  • If the site was just migrated, check whether the path still contains the old server’s home directory.

What Is the “Failed to Open Stream” Error in WordPress?

Failed to open stream is a PHP warning or fatal error, not a WordPress-only error. It appears when functions like require, require_once, include, include_once, fopen, or file_get_contents cannot open a file or path.

In WordPress, the message usually looks something like this:

Warning: require_once(/path/to/file.php): Failed to open stream: No such file or directory
Warning: fopen(/path/to/file): Failed to open stream: Permission denied
Fatal error: Failed opening required '/path/to/file.php'

The first line says the file could not be opened. When a require fails, PHP then adds the “Failed opening required” fatal error and stops. The reason text tells you which cause below applies.

Causes and fixes

1. The error is hidden until you enable debugging

Production sites usually hide PHP warnings, so you may only see a blank page, the “There has been a critical error on this website” message, or a broken admin screen. The real “failed to open stream” line is only in the logs.

How to check: Look for wp-content/debug.log or your host’s PHP error log (in hPanel or cPanel under Errors or Logs, or /var/log/php*-fpm.log and the web server error log on a VPS).

How to fix: Add this to wp-config.php above /* That's all, stop editing! */, reproduce the error, then read wp-content/debug.log:

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );

Set WP_DEBUG back to false when you are done.

2. The file does not exist

This is the most common cause. An incomplete plugin or theme update, a failed upload or migration, a partial backup restore, or a deleted file leaves code pointing to a file that is no longer there. The reason text is No such file or directory.

How to check: Run ls -l /full/path/from/error.php over SSH, or browse to the folder in File Manager or SFTP. If the folder exists but files are missing, the update or upload was incomplete.

How to fix: Reinstall the plugin or theme from a clean package. With WP-CLI: wp plugin install plugin-slug --force or wp theme install theme-slug --force. For a premium product, download a fresh copy from the vendor and re-upload it over SFTP.

3. A WordPress core file is missing or corrupted

If the path points into wp-admin/ or wp-includes/, a core update failed, someone edited core, the site was restored from an incomplete archive, or malware removed or replaced files.

How to check: Run wp core verify-checksums. It lists every core file that is missing or does not match the official release for your version.

How to fix: Back up the site, then reinstall core without touching wp-content or wp-config.php: wp core download --force --skip-content --version=$(wp core version). Without WP-CLI, upload the wp-admin and wp-includes folders from the same WordPress version over SFTP. If checksums show unexpected modified files, treat it as a possible hack.

4. The path in the code is wrong or left over from a migration

The file exists, but the code looks in the wrong place. This happens with hardcoded absolute paths in functions.php, custom or must-use plugins, relative includes that break when the working directory changes, and paths that still point to the old server after a move (for example /home/olduser/public_html/).

How to check: Compare the path in the error with where the file really is (find /path/to/site -name "file.php"). Search for hardcoded paths: grep -rn "/home/olduser" wp-content/ wp-config.php. Also check wp option get upload_path, which should normally be empty.

How to fix: Replace hardcoded paths with WordPress and PHP path helpers, for example require_once __DIR__ . '/inc/file.php';, plugin_dir_path( __FILE__ ), or get_template_directory() . '/inc/file.php'. After a migration, fix old paths in config and the database with wp search-replace '/home/olduser/public_html' '/home/newuser/public_html' --dry-run, then run it without --dry-run.

5. File permissions or ownership are wrong

The file exists but PHP cannot read it. The reason text is Permission denied. This often happens after migrations, SFTP uploads as another user, restores run as root, or security hardening.

How to check: Run ls -l /full/path/from/error.php and check the owner and mode. Then check which user PHP runs as: ps aux | grep -E 'php-fpm|lsphp' | head. If the file is owned by root or another user and is not readable by the PHP user, this is the cause.

How to fix: Set standard permissions and the correct owner (replace user:group with the PHP user):

find /path/to/site -type d -exec chmod 755 {} \;
find /path/to/site -type f -exec chmod 644 {} \;
chown -R user:group /path/to/site

On shared hosting, use the host’s “Fix file permissions” tool if it has one, or ask support to reset ownership.

6. A plugin or theme conflict broke the include

Plugins and themes load their own PHP files. A bad update or a reference to a file from another plugin that is inactive or renamed causes this error right after an install or update.

How to check: The path in the error usually names the plugin or theme folder. If not, disable all plugins with wp plugin deactivate --all (or rename /wp-content/plugins/ to plugins_off) and test. Then switch to a default theme with wp theme activate twentytwentyfour or rename the active theme folder in /wp-content/themes/.

How to fix: Re-enable plugins one by one until the error returns, then reinstall, roll back, or replace that plugin and report it to its developer. If the theme is the cause, reinstall it or fix the include in its functions.php.

7. open_basedir or another server restriction blocks access

The file exists and permissions look correct, but PHP is only allowed to open files inside certain directories. The error then says Operation not permitted or mentions open_basedir restriction in effect. This is common on shared hosting and hardened servers.

How to check: Run php -i | grep open_basedir or create a temporary file with <?php echo ini_get('open_basedir');, open it in the browser, and delete it afterward. If the path from the error is outside the listed directories, this is the cause.

How to fix: Move the file inside the allowed tree, or add its directory to open_basedir in the PHP-FPM pool (php_admin_value[open_basedir] = /home/user/public_html:/tmp) or the hosting panel’s PHP settings, then reload PHP-FPM. On shared hosting, ask support to change it.

General troubleshooting

Check logs beyond WordPress

Do not rely only on debug.log. Also check PHP error logs, web server logs, hosting error logs, and security plugin logs if they block file access.

Compare working and broken parts of the site

If only one plugin page, only the admin, or only uploads fail, the problem is specific to that path or plugin. If everything fails, look at core files, permissions, or server policy.

Check for partial updates and incomplete deployments

If the error started right after an update, deployment, or restore, suspect an incomplete file set first: a plugin folder with missing files, a version uploaded halfway, or one environment working and another not.

Test after every change

Do not change permissions, replace files, disable plugins, edit paths, and update WordPress all at once. Make one change, retest, and move on only if needed.

Prevention Tips

  • Avoid hardcoded absolute paths in custom code when possible.
  • Use clean deployments and verify file integrity after updates.
  • Back up plugins, themes, and the database before major changes.
  • Check ownership and permissions after migrations.
  • Do not edit WordPress core files directly.
  • Use staging for major plugin or theme updates.
  • Keep debug logging available for troubleshooting, but not publicly displayed.
  • Document any custom path or server restrictions like open_basedir.

When to Contact Support

Contact your hosting provider if:

  • the file exists but PHP still cannot access it,
  • permissions keep resetting,
  • open_basedir or server policies may be blocking access,
  • you need access to server logs or PHP configuration.

Contact the plugin or theme developer if:

  • the error started after their update,
  • the missing file belongs to their code,
  • the issue disappears when their product is disabled.

FAQ

What does failed to open stream mean in WordPress?

It means PHP tried to open a file or path and failed. The most common reasons are a missing file, wrong path, bad permissions, or server restrictions like open_basedir.

How do I fix failed to open stream in WordPress fast?

Read the full error message, find the exact file path, verify the file exists, fix the path or permissions, and disable the recently changed plugin or theme if needed. Enabling WP_DEBUG_LOG is often the fastest way to see the real source.

Can a plugin cause failed to open stream in WordPress?

Yes. Plugins often include their own files, and if an update fails or the include path is wrong, WordPress can throw this error.

Can permissions cause failed to open stream?

Yes. PHP must be able to read the file. Wrong ownership, restrictive permissions, or open_basedir can all prevent a file from being opened even when it exists.

Why did failed to open stream start after migration?

Because migrations often change paths, file structure, and ownership. Code or settings that still point to the old server’s directories will fail on the new one.

Related WordPress Errors

Leave a Comment