Fix the WordPress Failed to Open Stream Error

If a file is mentioned in a website code and if WordPress tries to load it and fails to do so, the Failed to open stream error gets triggered in WordPress. With this error being triggered, there could be two possibilities:

  • WordPress continues loading the site. It, however, displays a warning message.
  • A fatal error is displayed and everything stops working.

Whatever the situation is, we are here to help. To get a feasible solution to fix the WordPress failed to open stream error, you need to keep reading the article.

Error Message:

In the error message, the location of the error might be mentioned. But you most probably will be unable to understand this clue completely, unless you are a pro. Also, the error message may vary depending on the below two factors:

  • Where the error occurs in the code
  • Reason for failure.

Example: Error Message 1:

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

Example: Error Message 2:

Last Error: 2018-04-04 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’

Resolving the Failed to Open Stream Error in WordPress:

To start with the fix, first, try to locate the reason for the error in the error message itself. You will find something like,

  • Permission denied
  • No such file or directory
  • The operation failed, etc.

Case 1: The error message contains ‘no such file or directory:

For this case, you need to follow the below steps:

  • Check the code to find out the file mentioned at the specific line of error.
  • If the mentioned file is a plugin or theme, it might be deleted or not installed correctly.
  • Deactivate the respective theme or plugin.
  • Reinstall it.

One another possible scenario is that WordPress can’t locate the files. The reason could be a missing .htaccess file. This file should be present in your root folder. In this case, you can follow the below steps:

  • Go to your WordPress admin.
  • Go to Settings » Permalinks page.
  • Click on the Save Changes button.

  • The .htaccess file will be regenerated.

Case 2: If the error message is followed by ‘Permission denied’:

This simply means that WordPress can’t access the file or directory referenced in the code because of the absence of the right permission. In this case, you have to take two important measures. These are:

  • Check for the WordPress files and directory permissions.
  • Make the right permissions.

Case 3: Operation failed:

There are many third-party sources from where scripts are loaded by the WordPress plugins. Some of these third-party sources are:

  • Google Analytics
  • Facebook APIs
  • Google Maps
  • Other third-party APIs.

Now, there are two possible scenarios where WordPress might fail to open the required files. These are:

  • APIs are asking for authentication.
  • There are some modifications in the way these APIs can be accessed.

Here, we recommend you contact the plugin author for proper assistance.