Fix Fatal Error: Maximum Execution Time of 30 Seconds Exceeded
Have you tried updating a theme or plugin and got the ‘Fatal error: Maximum execution time of 30 seconds exceeded’? If you have then this post is for you and will teach you how to fix this error. Often, this error will occur when the PHP code in WordPress takes longer to run and reach the maximum time limit set by the WordPress hosting server. The purpose of the time limit is to prevent abuse of the server resources. But how can you fix this issue? Here is how.
Why the error occurs
WordPress is coded in PHP. In order to protect web servers from being abused there is a limit on how long the PHP script can run. The limit varies from one hosting company to the next. In most cases, the maximum execution time is 30 to 60 seconds. The reason for this is because this is enough time to the PHP script to run. When the maximum limit is reached, you will get the maximum execution time exceeded error.
Fixing the error
Although the error is named ‘fatal error’, it is the most common WordPress errors and can be resolved easily. The error you get will vary depending on what actually triggers the error. You may also get the error that looks like this:
The site is experiencing technical difficulties.
The above is the fatal error protection feature that was added in the new WordPress 5.2. You might also get an email about the plugin that triggered the error. The email includes a link that directs you to the ‘Recovery Mode’. If the error was caused by a plugin all you need to do is delete or deactivate the plugin. If you don’t wish to deactivate or delete the plugin you can simply fix the cause of the error. To do this you will have to edit the .htaccess file manually.
Exiting the .htaccess file requires that you connect to the website using FTP client. The .htaccess file will be found in the same folder as the /wp-content/ and the /wp-admin/ folders.
After locating the .htaccess file you need to right click on it and open ‘view/edit’ option. This opens to a text editor. You now need to add the following line at the very bottom of the .htaccess file:
php_value max_execution_time 300
Save the edited file. The code will set the value for the maximum execution time to 300 seconds. That is 5 minutes. You can now go back to your website and see if the error is fixed. If the error is still there you can increase the value to 600.