How to Fix the Max_Execution_Time WordPress Error

The max_execution_time WordPress error is a common error that most WordPress users encounter at some point while operating their site.

The error is related to the incomplete execution of a PHP script due to time constraints.

In this troubleshooting guide, you’ll learn what PHP scripts are, why they are subject to time constraints, and what steps you need to take to remove the max_execution_time WordPress error from your site.

Let’s get started with the tutorial.

What is the max_execution_time WordPress error? What causes it?

WordPress along with plugins and themes is coded in the PHP programing language. This means that when you are operating a WordPress website PHP scripts are constantly being executed.

By default, script executions are often subject to a 30-second time limit by your hosting server. It is done to prevent the overuse of server resources.

This number can be higher or lower at certain hosting providers – but most hosts use a default configuration of 30 seconds.

If a script does not complete execution within the 30 seconds time frame, then the function is terminated and you are shown the max_execution_time error.

In most cases, this particular error occurs when you are trying to install or update a plugin or theme.

The max_execution_time WordPress error can also be displayed with different messages.

For example, sometimes you’ll see a message like the following in your WordPress dashboard: Fatal error: Maximum execution time of 30 seconds exceeded.

On the frontend of your WordPress site, this error can also show up as a generic WordPress error message: The site is experiencing technical difficulties.

Now that you know why the max_execution_time WordPress error occurs, let’s learn how to fix it.

How to fix the max_execution_time WordPress error?

In this section, we are going to discuss two types of solutions: permanent and temporary.

The permanent solution involves deactivating plugins and themes. Carrying this out immediately might not be possible for many of our readers which is why we are also offering a temporary solution.

If the temporary solution is more suitable for you, then implement that but be sure to carry out the permanent solution sometime soon or else you risk encountering the max_execution_time error again and again.

  • 👉 Permanent fix
  • 👉 Temporary fixes

Permanent fix

We know that the max_execution_time WordPress error occurs due to time constraint on a PHP script. But we still need to know what PHP script was being executed to fix the error.

In most cases, people encounter this error while installing a plugin or a theme. This means the plugin or theme is causing the error.

The PHP execution time limit set by the hosting provider is enough to allow most plugins and themes to work properly.

But poorly coded or malware-infected plugins and themes need more resources to function. So, to fix the max_execution_time error, you need to remove the plugin or theme from your website and replace it with an alternative.

If you started experiencing the error immediately after installing a new plugin or theme, that’s a pretty good sign that the issue comes from that extension.

Multiple updates of plugins and themes are also known to cause the error. So we recommend avoiding bulk updates and implementing updates one by one.

If the error appeared when you were not operating your site, even then there are ways to figure out the real cause of the error.

  • The error itself may have a file name giving you clues as to what caused it.
  • WordPress (if you have version 5.2 or above installed) may have sent you an email revealing which plugin, theme or software triggered the error.

They would have also sent you a special link using which you can open your site in the Recovery Mode. The Recovery Mode is needed when your site stops functioning due to a fatal error. This particular error, although called a fatal error does not prevent your site from functioning normally. So while you don’t need to access the Recovery Mode to delete the culprit plugin or theme, there’s no harm in using it.

Temporary fixes

A temporary fix for the max_execution_time WordPress error involves increasing the maximum PHP execution time.

You can attempt to do this by using one of the four methods below:

  1. a dedicated plugin
  2. wp-config.php file
  3. .htaccess
  4. php.ini

However, it’s worth noting that the success of these methods will depend in part on your hosting environment and how it’s configured.

Method 1: Increase PHP execution time using a plugin

While there are a couple of plugins in the WordPress repo that allow you to increase the PHP execution time, at the time of writing this article WP Tools by Bill Minozzi is the only plugin that is being updated regularly. Therefore, we recommend using this plugin. We also recommend checking the WordPress repo page of the plugin to ensure that it’s being updated at the time of reading this article.

Download WP Tools and install it on your WordPress website. As soon as you do that, a WP Tools option will appear on your dashboard menu.

Go to WP Tools → Settings → General Settings and you should be able to see an option called Add Max Execution Time Limit.

It will show you your current execution limit which can be increased to 120 sec from the dropdown menu.

Try updating or installing the plugin or theme that was triggering the error. If it’s still showing the error, then you probably need to increase the time limit to 300 sec.

This can be done using the WP Tools plugin but you need to upgrade to a premium version of the plugin. We recommend increasing the time limit manually instead. In the next few sections, we have covered the manual method.

Method 2: Increase PHP execution time using wp-config.php

You can modify your site’s wp-config.php file using cPanel File Manager or an FTP client. We have covered how to use an FTP client like Filezilla in a different guide. So in this tutorial, we will show you how to use cPanel.

The first thing you need to do is take a backup of your website. This is very important. You will be making changes to a crucial file and if things go wrong, you might end up breaking your site. The backup will be your safety net.

Open your hosting account and locate cPanel.

Then open the File Manager, go to the public_html folder and you will find the wp-config.php file within that folder.

Right-click on the wp-config file and select the Edit button.

Scroll down to the end of the file and right above the line “/* That’s all, stop editing! Happy blogging. */” insert this code:

set_time_limit(300);

Hit the Save Changes button and close the tab.

Method 3: Increase PHP execution time using .htaccess

If your web server supports .htaccess (Apache and LiteSpeed), you can also increase PHP execution time using the .htaccess file.

You can access the .htaccess file by opening your hosting account and going to cPanel → File Manager → public_html → .htaccess. Right-click on the file and hit the Edit button.

Then insert the following code at the end of the file:

php_value max_execution_time 300

Save your changes and exit the file.

Method 4: Increase PHP execution time using php.ini

Log into your hosting account and go to cPanel → File Manager → public_html → php.ini. Edit the file by right-clicking on it and selecting the Edit button.

Go to the end of the file, insert the following code, and save your changes:

max_execution_time = 300

If you don’t see the php.ini file, you might need to enable hidden files. Or, your host might offer a separate php.ini editor tool.

Nothing worked? Seek help from hosting

If both the permanent and temporary fixes fail, then there might be an issue with your hosting provider. Reach out to your hosting’s support team. Inform them about all the steps you have already taken. They should be able to help you remove the error from your site in no time.

How to prevent max_execution_time error in the future

In most cases, the max_execution_time WordPress error occurs either when you are updating a plugin or theme or installing one.

To prevent the error from occurring in the future, you need to take the following steps:

1. Update plugins one by one

Avoid updating plugins all at once because multiple updates tend to overwhelm the server and could trigger errors like the max_execution_time WordPress error.

2. Use a staging site during updates

A staging site is a replica of your WordPress website. You can carry out updates on this site as if it was your live site. This will ensure that post-update issues are restricted solely to your staging site.

3. Download plugins and themes from trusted sources

We mentioned earlier how poorly coded plugins and themes hog more time and resources to execute PHP scripts. So you need to ensure that you are using well-coded software on your site. The problem is it’s difficult to tell which plugins and themes are well-coded and which ones are not.

The best way to ensure the quality of a plugin or theme is to download them from the WordPress repo, popular developer websites, like Themeisle, aThemes, Astra Themes, etc., or marketplaces, like CodeCanyon, ThemeForest, TemplateMonster, MojoMarketplace, etc.

Fix the max_execution_time WordPress error for good 🦸‍♂️

The max_execution_time error is a common WordPress error and it can be easily fixed by removing the culprit plugin or theme from your website.

If you have a high dependency on the plugin or theme and don’t want to delete it immediately, increasing the PHP execution time limit can be implemented as a temporary fix. Just remember that the actual culprit is still on your site and needs to be replaced with an alternative.

Did you find this article useful?