If you are seeing “fatal error: maximum execution time exceeded” when accessing your WordPress site, it means a part of your WordPress code is taking too long to execute. There is a maximum execution time for PHP scripts. If a script takes longer, this fatal error occurs. To fix it, you’ll need to increase the WordPress max_execution_time.
The words “Fatal Error” can be alarming, but gladly, you can fix this problem with a little effort.
This guide shows you a quick fix for the fatal error: maximum execution time exceeded issue so you can get your site back online. We also show you a more thorough fix that helps you locate and solve the underlying problem.
In this article:
- What Causes Fatal Error: Maximum Execution Time Exceeded in WordPress
- The Quick Fix (Stop Seeing the Error and Get Your Site Back Online)
- The Better Fix (Find the Underlying Problem and Fix It to Get Your Site Back Online)
What Causes Fatal Error: Maximum Execution Time Exceeded in WordPress?
Web servers set a time limit on how long a script can run. This is done to prevent the web server from abuse. Since WordPress is made up of PHP scripts, each script has to run completely within the set time limit.
This time limit is usually 30 seconds, and in most cases, this is more than enough time for a script to run. However, if a PHP script runs for longer than the set time limit, PHP cuts short the execution. It then returns the fatal error: maximum execution time exceeded message as seen in the image below.
The Quick Fix (stop seeing the error and get your site back online)
Since this error indicates that the time limit set is not enough for one of your scripts to run, you can quickly fix it by increasing the time limit.
The easiest way to increase the limit is by installing the WP Maximum Execution Time Exceeded plugin. All you need to do is install the plugin and your time limit is increased. If, in the future, you want to reset the time limit to default values, simply uninstall the plugin.
This plugin increases your execution time limit by adding a configuration to your .htaccess file.
Thus, if you prefer not to add a plugin for something this simple, you can simply increase the WordPress max_execution_time directly in your .htaccess file (we recommend this option).
Increase Maximum Execution Time Using .htaccess
To do this, access your server using FTP, and open the folder containing your WordPress files.
In this folder, search for the .htaccess file. When found, right click on it, and click View/Edit.
Next, add this line to the bottom of the file (this increases the time limit from 30 seconds to 2 minutes):
php_value max_execution_time 120
Now save this file and close it. FileZilla will prompt you to upload the new file. Click Yes. And that’s how to manually increase the execution time limit.
Fix PHP Execution Time Error using wp-config.php
You may also increase the max_execution_time in WordPress by editing the wp-config.php file.
For this, locate the wp-config.php file from the root directory containing your WordPress files. Here, right click on the file and select View/Edit.
After that, add the line of code below to the file. Ideally, this should be added just before the “that’s all, stop editing…” line.
Once done, save the file. You will be prompted to reupload the file. Select Yes. This will increase the PHP Execution time to the value you specified in the config file.
The Better Fix (find the underlying problem and fix it to get your site back online)
The solution above fixes the Maximum Execution Time Exceeded problem, but it is essentially a patch. You are increasing the memory limit to accommodate a script that is taking too long to run.
The better solution is to find the script that is taking too long to run and to get rid of it.
It is very unlikely that one of your WordPress core scripts is to blame. These scripts are coded to stringent standards.
Thus, you should look towards your themes and plugins to find the time-consuming script.
If you have already increased the time limit in the step above, you want to first return it to the default value (either by uninstalling the plugin or deleting the line you added to .htaccess). This will cause the problem to re-appear, but that’s what we want.
In some cases, WordPress will specify what is causing the error on your site. If it is a faulty plugin, you will see a notification with details on the plugin(s) that led to this error.
You can then uninstall the faulty plugin and the WordPress max_execution_time error will be fixed on your website. However, if WordPress does not show the faulty plugin, you can troubleshoot using the steps below.
Disabling Your Plugins
To trace the problem, let’s start with your plugins. If the problem goes away when you disable your plugins, then a faulty script in one of your plugins is to blame. Read this article to learn how to disable plugins and how to find the particular plugin causing your issue: How To Disable WordPress Plugins Using FTP.
If you can find the plugin containing the time-consuming script, simply delete it. If you need the functionality offered by the plugin, you can always get another with similar functions.
Disabling Your Currently Active Theme
If disabling your plugins did not solve the issue, then your active theme is likely to blame. Follow this guide: How To Disable WordPress Theme Using FTP.
If disabling your theme removes the error, then the faulty script is in your theme. You will have to delete the theme and reinstall a fresh copy or use another theme entirely.
Fatal Error: Maximum Execution Time Exceeded – Conclusion
Disabling your plugins and (or) active theme would help you locate the script that is taking too long to run. Removing this script is the real solution to this fatal error.
WordPress max_execution_time is in place to prevent server abuse, so increasing it is a workable fix, but not really a solution. It’s only a way around the problem.
If the error persists after disabling themes and plugins, you can use the quick fix (increase time limit) to get your site back online for now, while you try to find and delete the slow loading script.
One thing to consider is if you have recently done some development work on your WP site. If so, one of the scripts added to your site could be causing the problem.
Also, although it is highly unlikely that a core WordPress file is responsible, you might consider updating WordPress to see if this removes the slow-loading script.
- WordPress User Roles: Beginner’s Guide
- How to Combine External CSS in WordPress
- Integrate Stripe in WooCommerce using WooCommerce Stripe Payment Gateway Plugin