When it comes to designing websites, most people go with WordPress, due to its simplicity. The market share of WordPress CMS is 42% of the overall share which means that more than two out of every five websites use WordPress these days. Having a Website with WordPress involves the security of the website and maintenance too. When you get trapped in errors with your WordPress website, it is very important to be able to troubleshoot the issues. One such common error in WordPress is a failed opening that requires a fatal error. We bring you how to fix failed opening required error in WP website so you do not have to freak.
In today’s post, we are going to check what is failed opening required error is, why it occurs, and how to fix a failed opening required error. So without further due, let’s begin the troubleshooting.
What is a failed opening required error?
Before we jump to what is failed opening required error is, we should know what it begins with. PHP is a widely used server-side scripting language and WordPress is primarily built using PHP. Now, a failed opening required error in WordPress is not actually from WordPress, it is a part of PHP standard error messages like (Syntax Error or Parse Error, Fatal Error, Warning Error, and Notice Error). The failed opening required message is a fatal error of the PHP language. Why it occurs you ask? let’s check that in below.
Why it occurs?
As we know, a failed opening required message is a fatal error from PHP, we would be checking why it occurs from a WordPress standpoint. The main reason behind a “failed opening required” is when a core file of WordPress has a reference in another core file that is missing or does not exist in the file path it is mentioned. From the above screenshot, if you check the point no one 1) the reference of class-wpdb.php file on line number 663 is in load.php and when class-wpdb.php goes missing or does not exist, it then throws the error.
Actually, it is not necessary that the missing reference would be of another WordPress core file, it can be of plugins or themes too. For example, let’s take point no 4) about the Coblock plugin fatal error from the above screenshot. In this case, the reference of loader.php on line 131 is in class-coblocks.php. In situations when loader.php goes missing or does not exist, it then errors out as shared in screenshot point no-4. Now there might be some reasons involved as to why the reference file would go missing or have problems, The reasons can be as follows.
File Integrity or manual file removal
Sometimes when we roam the file manager, we might just remove the file by mistake, or rename it which then turns out to be a cause of the failed opening required message. In a rare scenario, Developers can do this to their client’s website too if the Developer is not satisfied with the client with respect to the budget of the project or so. Sounds funny? but that’s what happens which I have seen being in the industry! There can be issues with the file integrity as well, for example, the file is completely missing, it is just missing as a result of wrong migration or lack of understanding in moving WordPress sites.
File permission or malware
The file permission for a file and folder under a Unix file system is 644 and 755. For files, the permission would be 644 and for folders, it is 755. On the other hand, the Windows file system would also have options to adjust the permissions over folders or files. The reason why we are talking about it is sometimes the file that reference is missing could have different permissions and in return, it generates the error. The other possibility would be the file being affected by malware attacks or other injections.
Software is entitled to have major or minor updates every now and then. Suppose you developed the website with WordPress version 6.2, and a new WordPress update is popped in but your site isn’t updated yet. Make sure your WordPress core and any related plugins or themes are up to date. Sometimes, updating can resolve compatibility issues that lead to missing or incorrect files.
Theme and plugin issues
The last would be something that comes due to outdated or faulty plugins or themes. It is very important to keep them updated from time to time. Well, if you find a fatal error, required once caused due to a certain plugin then it’s better to completely remove or replace its files. Let’s check how to fix this entire error below.
How to fix a failed opening required error?
step-1) Enable the debug mode first
The first thing is we need to know whether the issue that we are dealing with is the failed opening required or not. We can’t diagnose something that we don’t know about right? For this locate the document root of your website in question and navigate to the wp-config.php file. Once you are in the file, you need to change define(‘WP_DEBUG’, false) to define(‘WP_DEBUG’, true). Once that is done, save the file and reload your website in question.
Note: When you confirm the issue is only occurring due to the failed opening required, proceed further in the steps, if the error after enabling the debug mode is different than the failed opening required error then please stop and consult with your site admin or you can send us the information by commenting below or contact here.
We have divided this activity into 2 instances (Failed opening required due to a core file and due to a plugin). One is when one of the WordPress core file references is missing and on other instance is when one of the plugin’s core files is missing. Once the debug mode is enabled, you can call your website name in the browser in order to view the error. The error log would show the required information that we need to work on.
step-2) Failed opening required due to a core file
As per the above screenshot, we can deduce that there are 2 paths mentioned, I am writing them down as A and B.
- A – /home/user/public_html/wp-includes/class-wpdb.php
- B – /home/user/public_html/wp-includes/load.php on line 663
look closely, and read the lines again. You would figure that the reference of class-wpdb.php file (A) is in load.php (B) on line number 663. Let’s check if the file (A) is there in the location to confirm if the reference is present.
Verify the file exists
For this, you would need to go to path /home/user/public_html/wp-includes/ to find class-wpdb.php. You can use the File Manager utility to navigate to that path. Once you are in the path, check class-wpdb.php. You can see that the file is not present when we search it. This means that the reference class-wpdb.php (A) is missing which is called on load.php(B) and hence it’s giving the error.
Verify the WordPress Version
In order to fix this, you need to place the same file in that same location. But before you do that, you need to verify your WordPress location and then install the same WordPress version zip file from the download page of WordPress. Navigate to File Manager> wp-includes > and version.php file to verify the WordPress version.
Download the official Core file
When you have verified the WordPress version of your website. Next is to download the official WordPress version that matches your WordPress version. Access the link from here click on the WordPress version and download it. In my case, it is the latest one so I have downloaded the latest one. After downloading the zip file, unzip the file and check the path where it is likely to exist which is /home/user/public_html/wp-includes/, and search the file class-wpdb.php.
Upload the missing file
Now upload the same file that you have unzipped from to the hosting account where your WordPress website exists. Ensure to upload in the same location which is /home/user/public_html/wp-includes/. Once the file is uploaded, refresh the website and the issue should be fixed.
step-3) Failed opening required due to a plugin
In this section, we are going to check what to do when we get this error due to a plugin instead of a core file. As you can see in the screenshot, the error of failed opening required is caused due to a plugin coblock. We will use the same approach, but this time we will replace the file of that plugin in the same way. Before we do that let’s dissect the error first.
We can deduce from the above error that there are 2 paths mentioned. I am writing them down as A and B as follows.
- A – /home/techd/public_html/wp-content/plugins/coblocks/includes/block-migrate/loader.php
- B – /home/techd/public_html/wp-content/plugins/coblocks/class-coblocks.php on line 131
You would figure that the reference of loader.php file (A) is in class-coblocks.php (B) on line number 131. Let’s check if the file (A) is there in the location to confirm if the reference is present.
Verify the file exits
Use File Manager and go to/home/user/public_html/wp-content/plugins/coblocks/includes/block-migrate to find loader.php. Once you are in the path, check loader.php. You can see that the file is not present when we search it. This means that the reference loader.php (A) is missing which is called on class-coblocks.php (B).
Download the plugin locally
We are going to place a loader.php file, in order to do that, navigate to the WordPress repository of plugins from the link here. Search the plugin, its coblock, and download it. Now extract the same downloaded file and go to the path /home/user/public_html/wp-content/plugins/coblocks/includes/block-migrate and copy loader.php and upload it to your file manager. Ensure to upload in the same location which is /home/user/public_html/wp-content/plugins/coblocks/includes/block-migrate. Once the file is uploaded, refresh the website and the issue should be fixed.
Note: If the following steps don’t work for you, then you can consider replacing your WordPress core files. You may as well disable the plugins from the database. To replace the WordPress core file, check the blog here.
WordPress websites are easy to design but they might get you stuck when errors like Fatal error occurs. With the approach we have followed, is likely to fix the error of required once. If you are not sure whether you should follow the steps, it’s a good idea to check with your hosting provider first! This concludes how to fix failed opening required error in WP. Did this workaround work for your website? Please do let us know in the comments section below. If you need any help or have any suggestions to make, then do reach us via the contact page here. Happy National Candy Corn Day!