Coding Agency for Web Development » WordPress Development » How to Fix the Max Execution Time Error on WordPress: Increasing the Limit (Part 2)

How to Fix the Max Execution Time Error on WordPress: Increasing the Limit (Part 2)

READING TIME: MIN

And…. We’re back, wrapping up this series on handling the WordPress max_execution_time fatal error. In the preceding part, we described how the error occurs, and how we can remove the element that’s the cause of the error. This time, we’ll be taking a different approach – actually increasing the time limit – either with a plugin, by making changes to some files, or by just contacting your host. Read on to find out!

Increase the Time Limit with a Plugin

As discussed previously, this time limit exists for a good reason – protecting your server from unoptimized elements like themes and increasing your website security.

On the other hand, sometimes you legitimately need to give a particularly heavy element a little more time, or your hosting provider may have set a particularly sort time limit, so you’d be justified in increasing the time limit.

The quick way is a plugin that modifies the execution time configuration without having to actually access those files directly. For instance, you could use one of the many all-round plugins – such as Google PageSpeed Insights – where the max_execution_time value can be increased.

You could also try a dedicated plugin like WP Maximum Execution Time Exceeded that, once installed, edits the .htaccess file and sets the time limit to a whole 5 minutes by default. This is pretty generous, and any time you need to revert to your original limit, you just need to uninstall the plugin.

  Building a Scalable WordPress Framework for Growing Enterprises

For more customized time limits, talk to your WordPress agency for development and they will usually handle it for you, but if the hands-on method will need editing a few files in WordPress via (preferably Secure) FTP.

Increase the Time Limit by Editing Files – wp-config.php

For this first way, we’ll edit wp-config.php. Once you’ve opened the WordPress root directory over FTP, locate the ‘public’ folder and open it to reveal the file in question. Open it for editing and insert this line of code:

set_time_limit(240);

Preferably placing it at the end, right before it says ‘stop editing’, though the exact position isn’t an issue because the existing contents of the file are untouched. Save the file and reupload it if needed, and the time limit is now 4 minutes (or any other value you choose). Of course, ensure that the error has been dealt with.

error fix

 

Increase the Time Limit by Editing Files – .htaccess

In the same ‘public’ folder, there’s .htaccess, especially if you’re using a shared host that runs on Apache. Backup the file, open it for editing, and insert this code:

php_value max_execution_time 240

Use any other value you’d like, of course. Save and reupload .htaccess to the ‘public’ folder over FTP, and verify that the error no longer appears.

  WordPress for Enterprise: Building Robust, Scalable, and Secure Websites

Increase the Time Limit by Editing Files – php.ini

Next on our list is a less common file. If you find it in the ‘public’ folder, php.ini is another way we can increase the execution time available. On FTP, open the file and edit it by adding the code:

max_execution_time = 240

Feel free to use any value, but once the file is saved and re-uploaded, do check that you’ve fixed the error.

Increase the Time Limit by Talking to Your Host

On a dedicated server, all these methods will work great, but some shared hosts would want to protect their server, and may not even allow you to modify the execution time limit. In this case, contact your WordPress agency for development, or the hosting support directly, and inform them about the error you’re facing. Request the hosting provider to increase the time limit to somewhere in the 1-to-5-minute range, and if they can, that ought to be the last you see of this error.

Effortlessly resolved

Heavy PHP scripts in a WordPress element can bog your server down, and sometimes even trigger this error, causing you some trouble both in the backend and frontend. However, we hope that thanks to this tutorial, you now know it is hardly ‘fatal’ and effortlessly resolved.

  Enhanced Website Experience: The Why and The How of Custom Development

We’ll see you next time, with more tutorials and tips from our team here at Vipe Studio.

Tags:

Vipe Team

Author Vipe Team

Our tireless team who creates high-quality WordPress-related content for you 24/7/365.