Wondering how to resolve ‘Failed to open stream error in WordPress’? We can help you with it.
As a part of our Server Management Services, our Support Engineers helps to fix similar WordPress errors regularly.
Today, let us see how our Support Techs resolve ‘Failed to open stream error’.
Causes for Failed to open stream error in WordPress
Today, let us see cause for the error and it’s fixes.
Error occurs when WordPress is unable to load the file mentioned in website code.
Typically, this message would look something like this:
Warning: require(/home/website/wp-includes/load.php): failed to open stream: No such file or directory in /home/website/wp-settings.php on line 19 Fatal error: require(): Failed opening required ‘/home/website/wp-includes/load.php’ (include_path=’.:/usr/share/php/:/usr/share/php5/’) in /home/website/wp-settings.php on line 19
Also, here is another example:
Last Error: 2021-04-28 14:52:13: (2) HTTP Error: Unable to connect: ‘fopen(compress.zlib://https://www.googleapis.com/analytics/v3/management/accounts/~all/webproperties/~all/profiles?start-index=1): failed to open stream: operation failed’
Solution for Failed to open stream error in WordPress
Moving ahead, let us see how our Support Techs go about fixing this error.
The error can be caused by a variety of reasons and the error message will be different depending on the cause and location of the file that is causing the error.
In each instance, failed to open stream phrase would be followed by a reason. For example, permission denied, no such file or directory, operation failed, and more.
No such file or directory
Firstly, if the error message contains ‘no such file or directory’, look in the code to figure out which file is mentioned at that particular line.
If it is a plugin or theme file, it means the plugin or theme files were either deleted or not installed correctly. Simply deactivate and reinstall the theme/plugin in question to fix the error.
However, it is also possible that WordPress is unable to locate the files because of a missing .htaccess file in root folder. In that case, we need to go to Settings » Permalinks page in WordPress admin panel and just click on the ‘Save changes’ button to regenerate the .htaccess file.
Secondly, if the error message is followed by ‘Permission denied’, it means WordPress does not have the right permission to access the file or directory referenced in the code.
To fix this, we need to check WordPress files and directory permissions and correct them if needed. We can connect to WordPress site using an FTP client.
- Firstly, go to the root folder of our site and select all folders. Right-click the selected files and select properties.
We need to make sure that in the numeric value field, we have the number 755. Make sure that for owner permissions, the read, write and execute checkboxes are checked. For the group permissions and public permissions only the write checkbox should be unchecked.
Next, select the “all the files root folders” included and click properties.
Then, leave the numeric value field only. Make sure that under the owner permissions the read and write checkboxes are checked. As for the group and public permissions, only the read checkbox should be checked.
Finally, click OK to continue and the chosen FTP client will begin to set file permissions to the selected files on our WordPress site.
Some WordPress plugins load scripts from third-party sources like Google Analytics, Facebook APIs, Google Maps and other third-party APIs.
Usually, some of these APIs may require authentication or may have changed the way developers can access them. A failure to authenticate or incorrect access method will result in WordPress failing to open the required files.
To fix this, we need to contact the plugin author for support. They will be able to help us fix the error.
[Need any further assistance in fixing WordPress errors? – We’re available 24*7]
In short, this WordPress error triggers when WordPress is unable to load a file mentioned in website code.Today, we saw how our Support Engineers fix this error.