How to Fix WordPress max_execution_time Errors Quickly and Easily

How to Fix the WordPress Fatal Error Max Execution Time Exceeded

If you’re seeing the WordPress Max Execution Time Exceeded error, you’re not alone. This is a common error caused by a PHP script that isn’t completing within the allocated time.

While WordPress says it’s a ‘fatal’ error, it doesn’t mean it’s fatal to your website, only to that particular process. Your website’s front end should still be working as normal and you should still be able to perform other tasks.

It will be just that the particular task that gave you that error won’t be able to complete.

These errors can cause your website to become unresponsive though so you shouldn’t ignore it!

In this post, we will outline common causes of the error and walk you through several ways to address it.

By the end of this article, you should have fixed the error and be happily using your website once more!

What Is the WordPress max_execution_time Fatal Error?

code stock image

While WordPress will display the friendly version of the error, the actual syntax for this error is ‘max_execution_time’ rather than Fatal Error Max Execution Time Exceeded.

We’ll use both interchangeably.

Fatal Error Max Execution Time Exceeded is caused by a script within your website that didn’t complete within the PHP time limit.

WordPress has a time limit of 30 seconds built into it for each PHP script to execute and complete. The idea is to allow enough time for a function to complete but not give it so long that it hangs and freezes the entire site.

To that end, WordPress has a time limit set so PHP can execute a script and complete it.

If the script doesn’t complete in time, PHP will terminate it so it can move on to another and keep your website functioning.

Why Does the WordPress max_execution_time Fatal Error Occur?

code stock image 2

Most web hosts enforce PHP limits to preserve server resources. As WordPress is built on PHP, it’s a common target for hackers and malware but also uses up server resources that might be required for other functions.

Web hosts need to maintain efficiency while allowing every website on each server access to shared resources. A PHP time limit is one way to achieve that.

Most web hosts will place a PHP time limit of between 30 to 60 seconds to enable websites to use plugins, themes and scripts but also to keep things working.

If a script, plugin or theme is poorly coded or has been subjected to malware, it may exceed this time limit and produce the error.

It isn’t the most user friendly error you’ll ever see, so it’s important to understand that while it says ‘Fatal Error’, it is referring to that particular process and not your website!

How to Fix the WordPress max_execution_time Fatal Error

Fatal Error example

There are a few things you can do to fix the error. We’ll outline a few of them below.

First, we need to know what’s causing the error and stop it. Then we can work out any remedial actions afterwards.

Identifying the Cause of Fatal Error Max Execution Time Exceeded

Sometimes, WordPress will tell you what’s causing the problem. In the image above, you can see the error occurs during the plugin update process. This gives us a clue as to what’s causing it.

Other instances of the error will also give you a clue. Error messages with file names beside them can help identify the cause. Other messages with ‘Learn more about debugging in WordPress’ or something similar may also provide a clue

You may also receive an email from your WordPress website telling you what happened. This feature was introduced in WordPress 5.2 to help you identify plugins, themes or processes causing errors.

Check all of these to identify what went wrong.

If it’s a plugin, remove it or look for an update. You could also check the plugin’s website, use their support function or ask for help on its forum if it has one. If it happened to you, it likely happened to others.

If the error occurs during a WordPress plugin update, don’t select all the plugins at once. Select 4-5 plugins using the checkbox, update those and repeat until all your plugins are updated. Or use the new auto update feature in WordPress.

If it’s your WordPress theme, change it to the default Twenty Twenty-One theme and retest.

If you see this error frequently and it’s nothing to do with a plugin, you can manually extend the PHP time limit with a couple of file tweaks. There’s also a plugin for that if you prefer.

We recommend trying to identify the script that’s causing the error and addressing that directly rather than just extending the time limit. That time extension is just a workaround and isn’t addressing the root cause.

It’s up to you though.

Edit .htaccess

edit htaccess file

Your .htaccess file controls access to WordPress and access to some server resources. You can add a PHP time limit instruction within .htaccess to add more time for the script to complete.

  1. Log into your web host and access the file manager
  2. Navigate to your public_html file and select .htaccess
  3. Right click .htaccess and select copy
  4. Name the copy .htaccess.bk so you always have a spare
  5. Right click the original .htaccess file and select Edit.
  6. Add the following code to the file and save
php_value max_execution_time 300

Edit wp-config.php

edit wp-config file

You can modify the wp-config.php file to extend the PHP time limit and prevent the error. The same process as .htaccess, only this time you’re modifying wp-config.php instead.

  1. Log into your web host and use cPanel or their management tool to access the file manager
  2. Navigate to your public_html file and select wp-config.php
  3. Right click wp-config.php and select copy
  4. Name the copy wp-config.php.bk so you always have a spare
  5. Right click the original wp-config.php file and select Edit.
  6. Add the following code to the file and save
set_time_limit(300);

This should be enough to stop the error occurring.

Edit php.ini

edit php.ini file

You can also edit the php.ini file within WordPress to achieve much the same thing. If you’re not comfortable editing the very important .htaccess file, you make be more comfortable editing php.ini instead.

It’s almost exactly the same process as above.

  1. Log into your web host and access the file manager
  2. Navigate to your public_html file and select php.ini
  3. Right click php.ini and select copy
  4. Name the copy php.ini.bk so you always have a spare
  5. Right click the original php.ini file and select Edit
  6. Add the following code to the file and save
max_execution_time = 300

As you’re in a PHP file, you don’t need to specify that it’s for PHP.

Use the WP Maximum Execution Time Exceeded Plugin

WP Maximum Execution Time Exceeded WordPress plugin

Normally in our guides, if there is a plugin solution to a problem, we put that first. As this error is caused by a plugin, we appreciate you might be hesitant to use one plugin to fix an issue with another.

However, the WP Maximum Execution Time Exceeded plugin means you don’t have to modify any of your files to fix the PHP time limit issue.

The developer recommends taking a backup of your website before you install the plugin but if you follow the steps above to make a copy of your .htaccess file, that should be enough.

Then:

  1. Log into WordPress and select Plugins > Add New
  2. Search for Use the WP Maximum Execution Time Exceeded and select Install
  3. Select Activate once the option becomes available

There is no configuration with the plugin. It simply adds the code to your .htaccess file giving 300 seconds (5 minutes) to the PHP time limit.

How to Prevent the WordPress max_execution_time Fatal Error

Prevention is always better than cure and it’s no different with WordPress. If you’re unfortunate enough to experience website downtime as a result of the error, prevention is especially important.

There are a couple of ways you can do this.

Troubleshoot Plugins

WordPress plugins screen

If you think it’s a plugin causing the timeout, you can use the process of elimination to figure out which is causing it.

This will only work if the problem appears regularly. Intermittent errors are much more difficult to isolate.

  1. Disable all plugins and gradually activate them one by one
  2. Recreate the situation that causes the error
  3. Rinse and repeat one plugin at a time until you identify what plugin is causing the problem

Troubleshoot Your WordPress Theme

Activate different WordPress theme

It is rarely your WordPress theme that contains a script complicated enough to time out but it is possible. If you have tried troubleshooting your plugins with no luck or you hit the PHP time limit when updating the theme, that could be the culprit.

The simplest way to find out is to switch the theme for the default and retest it.

  1. Navigate to Appearance > Themes
  2. Select Twenty Twenty One and select Activate
  3. Try to recreate the error

If you can recreate the error with the default theme, it isn’t the theme at fault. If the error goes away, the theme is calling a PHP script that’s timing out. Follow up with the developer or upgrade your WordPress theme to Astra as we don’t use bloated scripts.

Ask Your Web Host to Increase max_execution_time

If your WordPress website has grown so much that scripts are regularly timing out, you may need to upgrade your hosting plan or ask your host to extend the time.

There are a number of scripts that can run within WordPress that slow down for larger sites. If this becomes a regular issue, you’ll need to discuss it with your host to explore your options.

The PHP Time Limit in WordPress

In the vast majority of cases, it’s a poorly designed plugin exceeding the PHP time limit causing WordPress max_execution_time errors. The process we outlined in this post for disabling plugins and testing them or increasing the PHP time limit should work.

If it’s something else causing timeouts, you now have the tools at your disposal to identify and troubleshoot them.

We hope it helps!

Have you experienced this error with a different cause? Have any other fixes for scripts hitting the PHP time limit WordPress? Share your thoughts below!

Join 304,719 Subscribers

Get exclusive access to new tips, articles, guides, updates, and more.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top

Download is Just A Click Away!

Be among the first to try the beta version of Astra’s Header Footer Builder. Filling the form will ensure you’ll be the first to learn about updates and features.

Download is Just A Click Away!

Enter your email address and be the first to learn about updates and new features.