How to Fix Failed to Open Stream Error in WordPress

Fix Failed to Open Stream Error in WordPress

When WordPress.Org releases a new update to it’s WordPress standalone CMS (Content Management System) for that you may have set your website to get your installation updated automatically or you may like to do it your self at your preferred time.

But because of server load on part of your web host, you may get an error ‘failed to open the stream’ on the screen.

This error usually points out the location of the scripts where the error has occurred. In this guide, I will show you how to easily fix the WordPress failed to open stream error.

But before digging deep, let me clear the basic knowledge about this error.

This error occurs when WordPress is unable to load the file mentioned in website code. When this error occurs, sometimes WordPress will continue loading the site and only show a warning message, while other times WordPress will show a fatal error and will not load anything else.

The message phrasing will be different depending on where the error occurs in the code and the reason for failure. It will also give you clues about what needs to be fixed.

Usually, the message will look like this:

Warning: require(/nfs/domains/your-domain-name.com/html/wp-includes/session.php) [function.require]: failed to open stream: No such file or directory in /nfs/domains/your-domain-name.com/html/wp-settings.php on line 122

Fatal error: require() [function.require]: Failed opening required '/nfs/domains/your-domain-name.com/html/wp-includes/session.php' (include_path='.:/usr/local/php-5.3.27/share/pear') in /nfs/domains/your-domain-name.com/html/wp-settings.php on line 122

There are different reasons that cause this error. In each instance, failed to open stream phrase would be followed by a reason. For example, permission denied, no such file or directory, the operation failed, and more.

But when your error message contains ‘no such file or directory’, then,

  • Look in the code to figure out which file is mentioned at that particular line.
  • If it is a plugin or theme file, then this means that the plugin or theme files were either deleted or not installed correctly.
  • Simply deactivate and reinstall the theme/plugin to fix the error.

Another cause includes that the WordPress is not able to locate the files because of a missing .htaccess file in your root folder.

Permalinks settings in WordPress
Permalinks settings in WordPress
  • Go to Settings » Permalinks page in your WordPress admin.
  • Click on the ‘Save changes’ button to regenerate the .htaccess file.

In case, the error message shows Permission denied, it suggests WordPress does not have the right permission to access the file or directory referenced in the code.

Check WordPress files and directory permissions and correct them if needed.

Download fresh WordPress file from the official site. Delete existing core files from your server directory except for the wp-config.php file and /wp-content/ directory. and upload freshly downloaded files to the server. This will replace all the core files without affecting your site settings and customization.

Conclusion:

Following the above steps, your website will start to function as normal as before. What else you tried, let me know in the comment section below.

LEAVE A REPLY

Please enter your comment!
Please enter your name here