SPECIAL OFFER Get 30% OFF on All Qode Plugins Discount code: WOOCOMMERCE30 SPECIAL OFFER Get 30% OFF on All Qode Plugins Discount code: WOOCOMMERCE30 SPECIAL OFFER Get 30% OFF on All Qode Plugins Discount code: WOOCOMMERCE30
SPECIAL OFFER Get 30% OFF on All Qode Plugins Discount code: WOOCOMMERCE30 SPECIAL OFFER Get 30% OFF on All Qode Plugins Discount code: WOOCOMMERCE30 SPECIAL OFFER Get 30% OFF on All Qode Plugins Discount code: WOOCOMMERCE30
BACK TO TOP

How to Fix the WordPress Failed to Open Stream Error

How to Fix the WordPress Failed to Open Stream Error

The WordPress failed to open stream error is one of the commonest WordPress errors that most WordPress webmasters have experienced. The naming for this error comes from the “failed to open stream” label that is part of the error messages that accompany the error. And, while this error can be easily solved by intermediate and advanced WordPress users, it is quite difficult to deal with for beginners, as it can break the website.

This is why we have decided to create this article, explaining the reasons behind the error and the methods of solving it. Therefore, if you have ever seen error messages similar to the ones shown below:

Warning: require(home/website/root/wp-includes/meta.php): failed to open stream: No such file or directory in home\website\root\wp-settings.php on line 112

Fatal error: require(): Failed opening required ‘home/website/root/wp-includes/meta.php’ (include_path=’.;C:\php\pear’) in home\website\root\wp-settings.php on line 112,

you shouldn’t worry anymore. This article will help you solve it in no time. We have subdivided it into sections just in case you have some idea of what is causing the issue. Having said that, let us begin.

Why Does the WordPress Failed to Open Stream Error Occur

Despite its rather odd and vague name, the WordPress Failed to open stream error occurs in very specific situations – when WordPress is unable to load a specific file which was requested. The file can be a part of a plugin, theme, or even within the core of WordPress. The consequences of this error can also vary depending on the importance of the file to the normal functioning of the website. In some cases, it can disable some functionalities on the website while letting you access and use it normally, while in others it can cause a fatal error, rendering you unable to log in or use the website.

That said, there are quite a few reasons why WordPress can’t load a specific file resulting in the aforementioned error. The file could simply not exist, or it could have been improperly installed on the website, WordPress might not have adequate permissions to access it, there could be some authentication issues when accessing it, other coding errors, including file name typos, and so on. Therefore, it is important to conduct the proper troubleshooting steps to pinpoint the exact reason behind the error and resolve it. Luckily, error messages will often reveal clues helpful for the troubleshooting process.

For example, a typical Failed to open stream error message could look as follows:

Warning: require_once() ( path-to-the-missing-file ): failed to open stream: explanation-for-the-error in path-to-the-file-that-is-requesting-the-missing-file on line XYZ

Fatal error: require_once(): Failed opening required ‘path-to-the-file-that-is-missing’ in path-to-the-file-that-is-requesting-the-missing-file on line XYZ

with the placeholder parts being replaced with corresponding file paths, explanation for the error, and code line, respectively.

While more advanced WordPress users can investigate the files indicated in the error messages thoroughly, even some basic understanding of how to interpret the message can go a long way. This includes figuring out which file is not being loaded, indicated by our path-to-the-missing-file placeholder, and the technical reason for the error, indicated by the explanation-for-the-error placeholder.

The former will let you understand if the missing file is a part of your theme, a plugin you installed, or part of the WordPress core files. The latter can point you to the best course of action. These technical explanations include labels such as “No such file or directory”, “Permission denied” or “Operation failed”. The first of these three is most commonly solved by reinstalling a part of your website (theme, plugin, or WordPress itself), the second by adjusting the file and folder permissions, while in the case of the last one, asking the plugin or theme authors for help is the suggested route.

Qode Themes: Top Picks
Bridge New Banner
Bridge

Creative Multi-Purpose WordPress Theme

Stockholm WordPress Theme
Stockholm

A Genuinely Multi-Concept Theme

Startit WordPress Theme
Startit

Fresh Startup Business Theme

What to Do Beforehand

Let us explore the methods of resolving this error. You can troubleshoot all the major reasons behind it, starting from the most obvious to the ones that are less so. However, to ensure the success of the troubleshooting process, some steps need to be taken beforehand.

Firstly, as the error has a typical error message, enabling the error log is an obvious prerequisite for establishing that the error is present. Furthermore, understanding at least the basics of how to interpret the error messages that are shown can help you greatly in resolving the error. For that reason, we advise consulting the previous section if you haven’t done so already. Additionally, as some steps might require the use of FTP, we also suggest brushing up your knowledge of FTP. Having done all that, you can proceed to the main troubleshooting process below.

Reinstalling a Plugin or Theme

As mentioned in the previous section, there are quite a few possible reasons for the error. However, the most common is that some plugin or theme files are missing or haven’t been installed properly, indicated by the “No such file or directory” label in the error messages.

Luckily, these error variations can be solved simply by reinstalling the plugin or theme. Of course, the first part of this process is figuring out which exact plugin or theme is the problem. To do so, you only need to examine the error messages according to the instructions given previously.

For example, if you had seen the following error messages:

Warning: require(/home/website/root/wp-content/plugins/plugin-name/includes/plugin.php): failed to open stream: No such file or directory in /home/website/root/wp-content/plugins/plugin-name/plugin-name.php on line 54

Fatal error: require(): Failed opening required ‘/home/website/root/wp-content/plugins/plugin-name/includes/plugin.php’ (include_path=’.:/usr/share/php’) in /home/website/root/wp-content/plugins/plugin-name/plugin-name.php on line 54

you would know that the relative path to the missing file is the following:

/wp-content/plugins/plugin-name/includes/plugin.php and you only need to reinstall the plugin named plugin-name.

Similarly, if the path to the missing file had contained the /wp-content/themes/theme-name/ part, you only need to reinstall the theme named theme-name.

While these are only examples, we hope they are instructive enough. That said, let us explain how to reinstall a plugin or theme.

If you still have access to your admin dashboard, you can simply reinstall a plugin from the Plugins screen. To do so, navigate to the Plugins > Installed Plugins section and locate the plugin shown in the error message. Then, click the “Deactivate” link below it to deactivate it.

Deactivate Plugin

Shortly hereafter, you will see the “Delete” link instead. To delete it, click the “Delete” link.

Delete Plugin

Then, you will need to reinstall it. To do so, navigate to the Plugins > Add New section and locate the plugin once more, by using the search feature or any of the plugin tabs. Having found it, click the “Install Now” button.

Install Plugin

Shortly after, the plugin will be installed and you can activate it by pressing the “Activate” button.

Activate Plugin

Then, you only need to examine the status of the error messages previously shown. If they are gone, the issue has been solved.

On the other hand, if you are unable to log in to your dashboard, you will need to disable the faulty plugin via FTP. To do so, we advise consulting our article on how to disable plugins when locked out of WP Admin. Then, having disabled it via FTP, you will be able to regain access and install it once more in the manner mentioned above.

As for reinstalling a theme, you can do so from the Appearance > Themes section, if you still have access to your admin dashboard. To do so, you will first need to enable a default WordPress theme by clicking the “Activate” button next to it. If you don’t have such a theme, you will need to install it.

Activate Theme

Then, you will need to delete your current theme via FTP and install it once more.

On the other hand, if you are unable to log in to the admin dashboard, then you will need to find an alternative way of switching the theme to a default one. Doing so via FTP is the most common way. Having enabled a default theme, you can proceed as mentioned above, i.e. to delete your current theme via FTP and install it once more. Then, you can review the status of the issue. If it hasn’t been resolved, you can proceed to the following troubleshooting step.

Reinstalling WordPress

What was said for plugin and theme files goes to some extent for core WordPress files. More precisely, if one of the WordPress core files wasn’t properly installed or is missing from the WordPress installation, it can cause the Failed to open stream error. In which case, the most likely error message variation would be the “No such file or directory” and would be pointing to a file located either in the wp-admin, wp-includes, or the root WordPress directory. An example for this kind of error variation is given in the article’s intro, pointing to the meta.php file that is missing from the wp-includes directory.

In most cases, these kinds of the failed to open stream error will lock you out of your admin dashboard, because an important file is missing from the default WordPress installation. Luckily, there is an easy solution for this subtype of the WordPress Failed to open stream error – reinstall the WordPress files. We will explain how to do it below, both in the case that you still have access to the admin dashboard and if you are locked out of it.

If you have access to the admin dashboard, you can reinstall WordPress by navigating to the Dashboard > Updates section. In this section, you will see the update status of your plugins, themes, and WordPress files. Users with the latest WordPress version will see a notification confirming it as well as a button which allows them to re-install that version, while others will see an update button which will allow them to update their current WordPress version to the latest one. To reinstall WordPress, simply press the “Re-install version” button.

Reinstall WordPress

After waiting for a while, your WordPress version will be successfully re-installed and you will be redirected to the page displaying all the fixes and features the new version brings. Of course, at this point, you only need to focus on verifying if the failed to stream error has been resolved by checking if the same error messages are still present. If they aren’t, it means that the issue has been resolved.

On the other hand, if you are unable to regain access to your admin dashboard, the process of reinstalling WordPress is quite different. You will need to download the WordPress files from the official WordPress.org download page and upload them to your server via FTP.

This will override any WordPress files that were previously installed, while also installing any that were missing and that have caused the error. As this is something that we have already covered previously, we advise reviewing the article on how to reinstall WordPress via FTP at this point. Then, check the status of the Failed to open stream error. If the missing WordPress core files were behind the error, at this point, you should regain access to your admin dashboard and will no longer see the error messages. But, if this wasn’t the case, then you should proceed with troubleshooting.

Saving Permalinks

Another possible reason for WordPress’ inability to locate the missing files could lie in the fact that your website may be missing the .htaccess file in the root WordPress folder. Luckily, this can be easily tested for.

If you have access to your admin dashboard, you will only need to navigate to the Settings > Permalinks section and click the “Save Changes” button at the bottom to regenerate the .htaccess file.

Permalinks

Then, you should investigate if the error has passed by checking the status of the error messages previously displayed. Of course, if you no longer see those error messages or any other, it means that the issue was successfully solved.

On the other hand, if you are unable to access your admin dashboard, you need to create the .htaccess file manually, via FTP. The .htaccess code which is part of most basic WordPress installations is given below:

# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

Of course, the code will be slightly different if you are running a multisite. In that case, we advise using one of the suggested code versions found in the official WordPress.org support article on the .htaccess file. As for the exact steps required to implement the code, we advise consulting our article on how to recreate the default .htaccess file. After performing the suggested steps, check if the error persists. If it does, proceed to the following troubleshooting step.

Properly Setting Up File and Folder Permissions

One of the reasons for the error is tied to not having the necessary permissions to access a given file or directory. This error variation is accompanied by the error message withs the words “Permission denied” in it. Here is a possible example of such an error message:

Warning: require_once(/home/website/public_html/wp-config.php): failed to open stream: Permission denied in /home/website/public_html/wp-load.php on line 37

Fatal error: require_once(): Failed opening required ‘/home/website/public_html/wp-config.php’ (include_path=’.:/usr/lib/php:/usr/local/lib/php’) in /home/website/public_html/wp-load.php on line 37

Therefore, if you have seen this or a similar error message, it only means you need to set the permissions on your WordPress files and folders properly to resolve the issue. This step should generally be performed as WordPress error messages change over time. But, having the permissions set on your WordPress files and folders properly secures that they can be read, written to, or executed accordingly.

For reference, the suggested permissions for folders are 755 or 750. For files, those are 644 or 640, and specifically for the wp-config.php file, the value should be either 440 or 400. You can adjust them via FTP, either using an FTP client or via cPanel. To find out more on the steps needed for this process, we advise consulting our article on how to set file and folder permissions in WordPress. Having done that, check the status of the error. If it hasn’t been resolved, proceed to the final step in our troubleshooting guide.

Asking Help From Plugin or Theme Authors

Finally, if the error messages point to a plugin or theme file, but any of the previous troubleshooting steps haven’t resolved the error, we strongly advise asking for further help from plugin or theme authors. Needless to say, you should refer to the authors of the file shown in the error message.

The reasons for the error vary significantly, ranging from simple typos in file names or code to complex ones like missing third party scripts or authentication errors when accessing third party APIs. Whichever the case, asking the professionals for help is the way to go after performing the initial troubleshooting steps previously discussed. Of course, when asking for help, make sure to supply the error log and state all the steps that performed before contacting them, as it will speed up the error resolution process.

Final Thoughts

The WordPress Failed to open stream error can be quite a headache for novice WordPress users, as it can deny them access to their website. Furthermore, it comes with seemingly hard-to-understand error messages which might frighten some users. Luckily, perusing this article carefully you will have learned how to “read” those error messages properly and apply the necessary troubleshooting steps to resolve the error.

These steps include reinstalling a plugin or theme, reinstalling WordPress core files, regenerating the default .htaccess file, setting the proper file and folder permissions, and asking for support from plugin or theme authors, all of which we have thoroughly explained.

This is why we are sure that you will be able to resolve the error with our help. And, with the knowledge you have gained, you will understand the cases in which each of these steps is used best, to optimize the troubleshooting process. Finally, as this is one of the many common WordPress errors, bookmarking this article for future use is something we strongly recommend.

Post your comment

Comments0