How To Fix The Maximum Execution Time Exceeded Error In WordPress: A Step By Step Guide

Did you know that WordPress powers 35.8% of websites on the internet? With a growing user base and easy-to-use features,WordPress remains the favourite CMS of many. There are some WordPress errors that can be fixed by yourself, without having to wait for a developer.

In this article, we are going to discuss the maximum execution time exceeded error. We all know that WordPress is written in PHP programming language; this guide shows a simple yet right way to fix this error without much programming knowledge or experience.

Let’s get started.

What is the maximum execution time limit in PHP?

When you try to access your WordPress site, there may be an instance when you will receive a message that says “Fatal Error: Maximum execution time exceeded.” Reading the words “Fatal Error” may be frightening, but worry not.

This message just simply means that the PHP code in WordPress took too long to execute than the allowed time limit. The WordPress hosting server sets a maximum time limit for code execution. When the PHP code execution reaches this maximum time limit, the message will appear and the server will stop the execution.

What causes this error?

PHP is the main programming language used in WordPress. Since PHP scripts are used to build WordPress, it is important to completely execute each script within a set time limit. WordPress sets an execution time limit to prevent the abuse of web server resources.

The exact time limit varies depending on the hosting company, but it is typically 30 seconds. This time limit is usually more than enough to execute a PHP script. However, if the execution of the PHP script exceeds the set time limit, the execution is cut short and returns the “Fatal Error: Maximum execution time exceeded” message.

How to increase the maximum execution time limit in PHP

The error reads as “Fatal Error”, but it is one of the most common errors encountered in using WordPress. Even if it says it is fatal, this problem caneasily be resolved. There are a variety of methods to fix this issue, which is done by increasing the maximum execution time limit.

Manually editing the .htaccess file

The .htaccess file is a server configuration file that instructs your server on how to respond to certain things on your website. This includes redirecting users, protecting the admin folder in WordPress by using passwords, and protecting some directories. You can manually edit the set time limit value if your PHP scripts need more execution time. Here is how you can do it:

  1. In the hosting provider’s cPanel, open the File Manager.
  2. Navigate to the public_html directory and double-click the .htaccess file.
  3. In the .htaccess file, insert the code: php_valuemax_execution_time 60

Note: Using this code will edit the set maximum execution time to 60 seconds.

Clear your browser cache and check if the error still exists

Manually editing the php.ini file

The php.ini file defines the PHP server settings. On many WordPress platforms, this may not be seen inside the WordPress folder. If this is the case, simply creating a new file is possible. Here is how you can do it:

  1. Inside your WordPress root folder, create a php.ini file.
  2. Open and edit the created php.ini file by adding the code: max_execution_time = 60

Note: You can edit this using Notepad. Using this code will edit the set maximum execution time to 60 seconds.

  1. Save and upload the changes.
  2. Clear your browser cache and check if the error still exists.

Manually editing the wp-config.php file

The wp-config file is a setup that is available on all self-hosted WordPress sites. During the installation process, this file is specifically generated to your site. It functions as a storage for your database information. Increasing the maximum time limit is also possible by editing the wp-config.php file.

Here is how you can do it:

  1. Inside your WordPress root folder, locate the wp-config.php file.
  2. Right-click and download the file.
  3. Open and edit the file by adding the code: set_time_limit(60);

Note: You can edit this using Notepad.Using this code will edit the set maximum execution time to 60 seconds.

  1. Save and upload the changes.
  2. Clear your browser cache and check if the error still exists

Changing max_execution_time value in cPanel

You can increase the set time limit by simply setting it directly from PHP Configurations in the cPanel. Here is how you can do it:

  1. In the hosting cPanel, open the Advanced section.
  2. Navigate to the PHP configurations and select the PHP Options tab.
  3. Scroll down the tab and look for the max_execution_time option.
  4. Increase the value as needed.
  5. Clear your browser cache and check if the error still exists

Installing a plugin

If you don’t want to modify and edit codes, an easy way to increase the maximum time limit is by installing a plugin. Google Pagespeed Insights is one recommended plugin as it is straightforward and regular updates are made by the developer. To use a plugin, here is how you can do it:

  1. After installation, activate the Google Pagespeed Insights plugin in your WordPress dashboard.
  2. Open tools and navigate to Pagespeed Insights.
  3. Locate Advanced Configuration.
  4. Increase the value of maximum time execution as needed.
  5. Save the changes you have made and the plugin will automatically modify the .htaccess file.

This plugin allows you to test the speed of your website. You got a bonus tip!

The recommended maximum execution time limit for WordPress

The default value of the PHP time limit for most hosts is 30 seconds. However, there might be instances that 30 seconds is too short and the script needs more time to execute. You are free to increase the time limit using the stated methods; however, the default settings are recommended since it is proven that they will work fine on most websites.

Try increasing the time limit gradually such as from 30 to 60 seconds which is shown as an example in the stated methods.

Conclusion

There are easy and quick methods you can do to resolve the “maximum execution time exceeded” issue. Using the stated methods will usually resolve the error.

However, if the error still appears, you may contact your WordPress hosting provider for assistance.

References:

https://w3techs.com/technologies/details/cm-wordpress

https://wordpress.org/support/article/editing-wp-config-php/