Have you encountered the “Fatal error: maximum execution time exceeded” error message in WordPress? It has quite the scary “Fatal error” wording, which may make beginners think their website is gone, but don’t worry, it is still there. This error has a very simple fix and is one of the common WordPress errors you will encounter on the platform.
Unlike many other error messages, a backup is not likely to fix this error. WordPress mainly uses the PHP coding language to perform its normal functions. Each PHP script will only have a small amount of time to finish. Not being able to finish the script will result in this error. Today, I will demonstrate how to resolve the “Fatal error: maximum execution time exceeded” error message in WordPress.
Why Does This Error Occur
This error message occurs because the script could not finish running in time. The default amount of time available is chosen by your web host. This error message is common when you are switching between web hosts. This is because the web host you are switching from may have a longer script time than the one you are switching to.
Of course, this can be changed manually, so it can be easily fixed. Manually changing this time is very easy, but if you make it too short, the error is likely to occur. Of course, every website is unique and you may have a custom script that requires a longer than normal run time.
How to Resolve the Fatal Error: Maximum Execution Time Exceeded in WordPress
Today, I will demonstrate how to resolve the “Fatal error: maximum execution time exceeded” error message in WordPress. There are a few ways to fix this error. The first way is to decrease your scripts runtime. There is no clear guide for this method because every script is unique and built for your website. If the script is as short as possible then the easiest solution is to increase the script time. You can either do this manually or use a plugin like WP Maximum Execution Time Exceeded. I will demonstrate both ways.
Before you begin, you will need access to your cPanel. The login information is provided to you by your web host when you create an account. I would recommend making a backup of your website whenever you are about to edit code.
Let’s start by logging into the cPanel and clicking on the File Manager option. The File Manager will allow you to access all of the files related to your website.
You need to locate your .htaccess file. Click on the public_html directory. You should see the wp-content and wp-admin folders. Locate the .htaccess file. Right-click on the .htaccess file and select the Edit option.
If you can not find the .htaccess file, then there are two possibilities. The first is that your website has not generated the .htaccess file. The second is that the permissions are not set up correctly.
A pop-up window will show up. This box will warn you to create a backup of your files before editing anything. This will ensure that you can revert your website back to when it was working if something goes wrong. Click on the “Edit” button. A new tab will open containing all of the code from the file.
Insert the following line of code into your .htaccess file: [ht_message mstyle=”info” title=”” show_icon=”” id=”” class=”” style=”” ]php_value max_execution_time 300[/ht_message]
Once you have inserted the code into the file, click on the “Save Changes” button to finish.
Congratulations, you have extended the PHP script run time to 300 seconds (5 minutes). If this is not enough change 300 to 600. Just remember to save your changes to apply the code.
Let’s start by clicking on Plugins and selecting the Add New option on the left-hand admin panel.
Search for WP Maximum Execution Time Exceeded in the available search box. This will pull up additional plugins that you may find helpful.
Scroll down until you find the WP Maximum Execution Time Exceeded plugin and click the “Install Now” button and activate the plugin for use.
This plugin works when it is activated. This will raise your maximum execution time to 300 seconds or 5 minutes. As I said in the last method, 300 seconds should be more than enough time for any normal script. If this does not resolve the error you will either need to locate the script that is taking so long or use the first method and set the time higher than 300 seconds.
Watch Your Scripts
Code is what makes a website run and many WordPress developers choose the platform to avoid code altogether. You can create a successful website without ever writing a single line of code, but that doesn’t mean you should. In fact, writing code is better than installing plugins, but, at the same time, messing up the code can cause errors.
The maximum execution time error is very easy to make as a beginner. Many beginners will write very simplified scripts. The issue with oversimplified scripts is that they are usually not very efficient. This will lead to longer run times that will slow down your website and cause this error. Always look online when adding code for the most efficient method.
Which method have you used to solve the maximum execution time exceeded error? Were 300 seconds enough to fix the error?
Author: Chris Racicot
Chris is the Support Manager at GreenGeeks and has been with the company since 2010. He has a passion for gaming, scripting and WordPress. When he’s not enjoying his sleep, he’s working on his guitar skills and fiddling with 3d printing.