Skip to content

WordPress "Failed to open stream": find the missing file

Fix the WordPress "Failed to open stream" error with "No such file or directory" on cPanel by reading the two paths in the message. You will find out whether an old username, a deleted plugin, an interrupted update or a firewall setting asks for the missing file, and repair it in that one place.

Your WordPress site on cPanel has stopped, and the error log shows “Warning: require_once(/home/…/wp-content/…): Failed to open stream: No such file or directory”, usually followed by “Fatal error: Uncaught Error: Failed opening required”. PHP was told to load a file, looked at the exact path it was given, and found nothing there. The message names two files: the one that is missing, and the one that asked for it, with a line number. Read those two paths first, because the fix belongs in whichever file holds the wrong path, not in the missing file. On a site that was just migrated or renamed, the usual culprit is a full path that still contains the old cPanel username.

What you’ll accomplish

  • Split the error into its parts and know which file to open next.
  • Tell the five common causes apart with one or two commands each.
  • Recognise each cause by name. They are an old hard-coded path, a deleted plugin or theme, an interrupted core update, a letter-case mismatch, and a firewall file loaded before WordPress.
  • Repair the path in the file that holds it, then confirm the site loads and the log stays quiet.
  • Recognise the look-alike errors (“Permission denied” and “open_basedir restriction in effect”) that need a different fix.

Prerequisites

  • A WordPress site on a cPanel account, and access to cPanel’s File Manager or Terminal (cPanel → Advanced → Terminal runs as your account user).
  • WP-CLI for the core-file checks. Run wp --info; if it prints a version, you have it.
  • PHP 7 or 8. PHP 8 capitalises “Failed to open stream”; PHP 7 printed “failed to open stream”. On PHP 7 the fatal line also reads “require_once(): Failed opening required” instead of “Uncaught Error”. Search your logs case-insensitively so you catch both.
  • Example values used below: current account newuser, previous account olduser, document root /home/newuser/public_html, PHP 8.1 from EasyApache. Replace them with yours.

How it works

When PHP runs require_once, require, include or include_once, it opens the path it was given. If that path starts with /, PHP uses it exactly as written and never searches anywhere else. Only a relative path, such as functions.php with no folder, gets searched along the include_path list. That is why the include_path part of the message rarely matters for WordPress: WordPress and most plugins build full paths.

A require that fails is fatal, so the page stops and visitors see either a blank page or “There has been a critical error on this website”. An include that fails only warns, and the page carries on with a piece missing. Either way, the full text lands in the PHP error log, not on screen.

Annotated Example output of a Failed to open stream warning: the missing file path containing the old cPanel username olduser, marked with a cross; the requesting file under the current account newuser with its line number; and the include_path, which is not used for full paths. Each part points to the command to run next.

The diagram splits a real-shaped message into three parts. The first path is the file PHP could not find. The second path, after “in”, is the file that asked for it, and “on line 9” is where. In this example the two paths disagree on the home folder: the request comes from /home/newuser/ but points at /home/olduser/. That mismatch tells you where to look, and it is the most common finding after a migration or a cPanel username change.

When the requesting file reads “Unknown” and the line is 0, no WordPress file asked for anything. PHP itself tried to load a file before WordPress started, through the auto_prepend_file setting (a PHP option that runs one file ahead of every script). Wordfence’s Extended Protection mode works this way.

Step-by-step

  1. Get the full message from the error log. The browser rarely shows the whole thing. On cPanel, PHP usually writes errors to a file named error_log in the folder of the script that ran, so start in the document root. cPanel → Metrics → Errors also shows the latest web server errors.
cd ~/public_html
grep -i "failed to open stream\|failed opening required" error_log | tail -n 2

Example output:

[13-Oct-2026 08:17:42 UTC] PHP Warning:  require_once(/home/olduser/public_html/wp-content/plugins/acme/init.php): Failed to open stream: No such file or directory in /home/newuser/public_html/wp-content/mu-plugins/loader.php on line 9
[13-Oct-2026 08:17:42 UTC] PHP Fatal error:  Uncaught Error: Failed opening required '/home/olduser/public_html/wp-content/plugins/acme/init.php' (include_path='.:/opt/cpanel/ea-php81/root/usr/share/pear') in /home/newuser/public_html/wp-content/mu-plugins/loader.php:9

If nothing comes back, try wp-admin/error_log too. If the newest entry is days old, the error you see now is something else.

  1. Check whether the missing file exists. Copy the first path from the message exactly.
ls -la /home/olduser/public_html/wp-content/plugins/acme/init.php

Example output:

ls: cannot access '/home/olduser/public_html/wp-content/plugins/acme/init.php': No such file or directory

That result is expected. Now remove the last part of the path and run ls again, one level at a time, until something exists. If the folder /home/olduser itself is missing, you have cause A below. If the plugin folder exists under your current home but not under the old one, also cause A. If the plugin folder is gone everywhere, cause B. If ls does list the file, your error most likely says “Permission denied” or mentions open_basedir; both are covered in Troubleshooting.

  1. Read the line that asked for it. Use the second path and the line number.
sed -n '9p' /home/newuser/public_html/wp-content/mu-plugins/loader.php

Example output:

require_once '/home/olduser/public_html/wp-content/plugins/acme/init.php';

A literal path in quotes means someone typed it, so you fix it here. If the line builds the path from a constant, such as WP_CONTENT_DIR . '/plugins/acme/init.php', the path is right and the file is genuinely gone (cause B or C). If the message says “in Unknown on line 0”, skip to cause E.

Cause A: a full path with the old username

Migrations and cPanel account renames move the files to a new home folder, but text inside files keeps the old path. Search the places that commonly hold one. The .user.ini and .htaccess files are often hidden in File Manager, so use Terminal or turn on Settings → Show Hidden Files.

cd ~/public_html
grep -rn "/home/olduser" wp-config.php .user.ini .htaccess php.ini wp-content/mu-plugins wp-content/*.php 2>/dev/null

Example output:

wp-config.php:94:define( 'WPCACHEHOME', '/home/olduser/public_html/wp-content/plugins/wp-super-cache/' );
wp-content/mu-plugins/loader.php:9:require_once '/home/olduser/public_html/wp-content/plugins/acme/init.php';

Edit each hit to the current path. Where the file sits under the document root, the portable fix is __DIR__ (the folder of the current file) instead of any full path, for example require_once __DIR__ . '/../plugins/acme/init.php'; in the mu-plugin. No output means the old path lives somewhere else. Widen the search and skip uploads, which is usually large and should hold media, not code:

grep -rln "/home/olduser" ~/public_html --exclude-dir=uploads

Cause B: a plugin or theme removed while something still needs it

WordPress handles a deleted plugin folder by itself: it deactivates the plugin and says so in the dashboard. The error appears when other code loads files from that folder directly. The usual suspects are a must-use loader in wp-content/mu-plugins, a child theme’s functions.php, or an add-on plugin. Cache drop-ins are the other classic: advanced-cache.php and object-cache.php, left in wp-content by a caching plugin that is now gone.

wp plugin list --skip-plugins --skip-themes --fields=name,status
ls -la ~/public_html/wp-content/advanced-cache.php ~/public_html/wp-content/object-cache.php

In the list, look for the plugin named in the missing path; must-use plugins and drop-ins appear too, with the status must-use or dropin. The ls line prints each drop-in that exists and “No such file or directory” for each one that does not. If wp plugin list itself stops with the same error, the broken require sits in a must-use plugin, because WP-CLI loads those even with --skip-plugins. Open the requesting file from the message and fix it by hand.

If the requesting file is a drop-in whose plugin is gone, rename the drop-in (for example to object-cache.php.off), then reinstall the plugin if you still want it. If it is a theme or loader file, reinstall the missing plugin or theme, or remove the require line.

Cause C: a core update that stopped halfway

When the missing path is under wp-admin or wp-includes, and the requesting file is a core file such as wp-settings.php, the update was interrupted. Check every core file against WordPress.org’s checksums. This command reads files only, so it works even while the site is down.

wp core verify-checksums

Example output:

Warning: File doesn't exist: wp-includes/class-wp-block-parser.php
Error: WordPress installation doesn't verify against checksums.

Re-copy the core files at the version you already run. The --skip-content flag leaves out the default themes and plugins, and your own plugins, themes and uploads stay as they are.

wp core download --skip-content --force --version="$(wp core version)"

Example output:

Downloading WordPress 6.8.3 (en_US)...
md5 hash verified: 3f1c9a7e52d84b06e8a2c4d19f07b6e5
Success: WordPress downloaded.

On a site in another language, add --locale=fr_CA (or your site’s locale) to keep the core language files. If a .maintenance file is still in the document root, delete it, or the site keeps showing the maintenance notice.

Cause D: the right file with the wrong letter case

Windows and macOS usually treat Init.php and init.php as the same file; Linux does not. A theme built on a laptop can work there and fail on the server. List the folder and compare the spelling with the message character by character:

ls ~/public_html/wp-content/plugins/acme/ | grep -i "init.php"

Example output:

Init.php

Rename the file to match the code, or fix the spelling in the code.

Cause E: “in Unknown on line 0” (a prepend file)

Example output:

PHP Fatal error:  Failed opening required '/home/olduser/public_html/wordfence-waf.php' (include_path='.:/opt/cpanel/ea-php81/root/usr/share/pear') in Unknown on line 0

This line has no “Uncaught Error” because PHP failed before any script started. When you optimise the Wordfence firewall (its Extended Protection mode), Wordfence creates wordfence-waf.php in the site root. It then adds an auto_prepend_file line pointing at it, in .user.ini, .htaccess or php.ini depending on how PHP runs. A migration copies that line with the old path. Find every copy, including in neighbouring folders:

find ~ -maxdepth 3 -name ".user.ini"
grep -rn "auto_prepend_file" ~/public_html/.user.ini ~/public_html/.htaccess ~/public_html/php.ini 2>/dev/null

Example output:

/home/newuser/public_html/.user.ini
/home/newuser/public_html/.user.ini:4:auto_prepend_file = '/home/olduser/public_html/wordfence-waf.php'

Correct the path in each match. In cPanel, Software → MultiPHP INI Editor → Editor Mode shows the same per-domain settings if you prefer a form. Open wordfence-waf.php too, because older copies can contain a full path that needs the same correction. The faster route is to delete the Wordfence lines instead. Once the site loads, open Wordfence → Firewall and click Optimize the Wordfence Firewall, so Wordfence writes fresh lines with the new path.

Two things trip people up here. The php command in Terminal does not read .user.ini, so php -i | grep auto_prepend only shows the server-wide value and can look clean while the site still fails. And PHP caches .user.ini for up to 300 seconds (user_ini.cache_ttl), so wait five minutes before you judge the fix.

Validate it works

  1. Load the page that failed, and one wp-admin page:
curl -s -o /dev/null -w "%{http_code}\n" https://example.com/
curl -s -o /dev/null -w "%{http_code}\n" https://example.com/wp-login.php

Example output:

200
200
  1. Confirm the log has stopped growing. Note the time, browse a few pages, and search again. Nothing newer than your fix should appear.
grep -ic "failed to open stream" ~/public_html/error_log

Run it twice a few minutes apart; the count should not change.

  1. Confirm no old path remains. grep -rln "/home/olduser" ~/public_html --exclude-dir=uploads should print nothing. For a core repair, wp core verify-checksums should end with “Success: WordPress installation verifies against checksums.”

Troubleshooting

  • “Failed to open stream: Permission denied”. The file exists, but your account user cannot read it, usually because a restore left it owned by root with mode 600. Run ls -la on the path. If the owner is not your user, ask your host to give it back to your account user, then set files to 644 and folders to 755.
  • “open_basedir restriction in effect. File(…) is not within the allowed path(s)”. This is a different check. The open_basedir setting limits which folders PHP may open, and the path is outside them. If that path holds /home/olduser, fix it as in cause A. Otherwise remove or widen the custom open_basedir value in MultiPHP INI Editor rather than moving files.
  • The error moves to a new file each time you fix one. A migration tool skipped the search-and-replace of file paths. Run the wide grep -rln from cause A once and fix every hit in a single pass.
  • WP-CLI also fails with the same error. It loads wp-config.php like the site does, and it still loads must-use plugins when you add --skip-plugins. Use --skip-plugins --skip-themes to get past regular plugin and theme code. If the path sits in wp-config.php or a must-use plugin, fix that file by hand first.

When this is the wrong approach

These steps fit a single, specific missing file. For a different fatal error, or an empty log, start from the broader triage in WordPress “There has been a critical error on this website” or the layer-by-layer WordPress 500 diagnostic. If hundreds of files reference the old username, the migration itself went wrong; restoring and re-running it with a proper path replacement is cleaner than editing files one at a time. And if you never installed the plugin named in the missing path, treat the requesting file as suspect and check it for injected code before you restore anything.

The PHP manual page for require_once and the WP-CLI reference for wp core verify-checksums cover the two tools this fix depends on.

Running WordPress that earns real money deserves an operator — Stack Harbor runs that stack under Enterprise WordPress; book an infrastructure consult.