How to Fix Fatal Error: Maximum Execution Time Exceeded in WordPress

How to Fix Fatal Error: Maximum Execution Time Exceeded in WordPress

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:

  1. What Causes Fatal Error: Maximum Execution Time Exceeded in WordPress
  2. The Quick Fix (Stop Seeing the Error and Get Your Site Back Online)
  3. The Better Fix (Find the Underlying Problem and Fix It to Get Your Site Back Online)
  4. Conclusion

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.

Edit htacces - fix fatal error: maximum execution time exceeded in wordpress

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

Add code to htaccess- fix fatal error maximum execution time exceeded in wordpress

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.

View/Edit WP config file

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.

set_time_limit(300);

editing wp-config

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.

FAQs for How to Fix “Fatal Error: Maximum Execution Time Exceeded” in WordPress

What is the “Fatal Error: Maximum Execution Time Exceeded” error in WordPress?

The “Fatal Error: Maximum Execution Time Exceeded” error occurs when your WordPress site takes too long to complete a task and hits the maximum execution time limit set by your web hosting server. This error can be caused by several factors, including poorly optimized plugins, themes, or scripts, or large amounts of data to process.

How do I fix the “Fatal Error: Maximum Execution Time Exceeded” error in WordPress?

There are several ways to fix this error in WordPress, including:

  • Increasing the maximum execution time limit in your server’s php.ini file
  • Adding a line of code to your site’s wp-config.php file
  • Using a plugin like WP Maximum Execution Time Exceeded or WP PHP Override to increase the execution time limit
  • Optimizing your site’s plugins, themes, and scripts to reduce processing time.

How do I increase the maximum execution time limit in my server’s php.ini file?

To increase the maximum execution time limit in your server’s php.ini file, follow these steps:

  1. Connect to your server via FTP or SSH.
  2. Locate your php.ini file in your server’s root directory or the directory where WordPress is installed.
  3. Open the php.ini file in a text editor.
  4. Find the line that says “max_execution_time” and increase the value to a higher number (e.g., 300).
  5. Save the changes to the php.ini file and upload it to your server.

How do I add a line of code to my site’s wp-config.php file to increase the maximum execution time limit?

To add a line of code to your site’s wp-config.php file to increase the maximum execution time limit, follow these steps:

  1. Connect to your site via FTP or SSH.
  2. Locate your site’s wp-config.php file in the root directory of your WordPress installation.
  3. Open the wp-config.php file in a text editor.
  4. Add the following line of code to the file: “set_time_limit(300);” (without the quotes), where 300 is the number of seconds you want to set as the maximum execution time.
  5. Save the changes to the wp-config.php file and upload it to your server.

Are there any plugins I can use to fix the “Fatal Error: Maximum Execution Time Exceeded” error in WordPress?

Yes, there are several plugins available that can help you fix this error, including WP Maximum Execution Time Exceeded and WP PHP Override. These plugins allow you to increase the maximum execution time limit without having to edit your server’s php.ini file or your site’s wp-config.php file.

How can I optimize my site’s plugins, themes, and scripts to reduce processing time?

To optimize your site’s plugins, themes, and scripts to reduce processing time, follow these best practices:

  • Use lightweight and well-coded plugins and themes.
  • Avoid using too many plugins and disable any that you’re not using.
  • Minimize the use of complex scripts and large amounts of data.
  • Use caching plugins and content delivery networks (CDNs) to speed up your site.
  • Regularly update your WordPress core, plugins, and themes to the latest versions.

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.

If none of the fixes above works on your site, you may need to hire a professional or contact your web hosting providers to help you fix the fatal error.

More Resources:

 This post was written by Mesheal Fegor

Mesheal Fegor is a Web/WordPress Developer and technical writer. His WordPress help articles have been featured on Kinsta and other sites. Mesheal holds a master's degree in computer science. His writing focuses on technical WordPress issues, ranging from core WordPress problems, to issues with WooCommerce, and more.

Last edited by: FixRunner Team