Fixing the Fatal Error: Maximum Execution Time Exceeded in WordPress

Nadejda

Nadejda Milanova · 07th May 2021·PHP

Fixing the Fatal Error: Maximum Execution Time Exceeded in WordPress

It’s normal for this error to occur when a PHP code in WP takes too long to run reaching the maximum time limit set by the hosting server. The time limit has been put on place so that it can avoid the abuse of server resources.

Today we will talk about how to fix this error.

When does the Maximum Execution Time Exceeded error occur?

It’s common knowledge that WordPress is coded in the PHP programming language. A time limit is set for how long a PHP script can run in order to avoid web server abuse.

Depending on the hosting company the time limit can vary, but in most cases, it’s set between 30-60 seconds which is usually sufficient for a good PHP script to run.

When the script reaches this time limit, that’s when the error occurs.

Maximum Execution Time Exceeded error

How to fix the error?

Although it’s called “fatal error”, this is a very common WordPress error which can be resolved easily.

Depending on the time and place the error is triggered, WP can show this error to your site’s visitors.

atal error

It’s part of the fatal error protection feature in WordPress 5.2. It’s possible that you may receive an email as well, stating which plugin (if that is the issue) triggered it.

tech issue

A link will be included in the email as well, allowing you to log into your WP dashboard using Recovery mode.

email link

You can now deactivate or delete the plugin which is the cause for the error.

If you don’t want to deactivate the plugin, you can work on fixing the issue causing the error.

To do this, you would need to manually edit the .htaccess file by adding a simple line of code.

Log into your site using the FTP client.

Now, locate your wp-content/ and wp-admin/ folders where the .htaccess is located. Once you do this, right-click and open the View/Edit option. The file will then open in a text editor.

FTP client

Add the following line at the bottom of your .htacess file:

htacess

Once you are done, don’t forget to save the changes.

The code will set the value for max execution time to 300 seconds or 5 min. Go to your website and check if the error remains.

If that didn’t work, try with increasing the value to 600.

Another method you could use is by modifying the php.ini file.

This is a configuration file which defines setting for PHP on the server. On a lot of WP hosting platforms, it’s not visible inside the WP folder.

If that’s the case, create a new php.ini file in your WP root folder. Then, edit the file by adding the following code:

php.ini file

The changes need to be saved and uploaded back to the server. Go back to your website and check if the error remains.

By increasing the execution time using one of the two methods above, you should be able to resolve the Maximum Execution Time Exceeded error. If this doesn’t work, get in touch with your WP hosting provider for further assistance.

Conclusion

This common error is in place to avoid server abuse, meaning that by increasing the time you do not fix the problem, just finding a way around it.

Also, if you have recently done some development work to your website, the problem could be one of the scripts.