Are you facing a ‘fatal error: Maximum execution time of 120 seconds exceeded’ on your WordPress website when trying to update a WordPress plugin or theme?
Normally, this problem happens when a PHP code in your WordPress website/blog takes a long time to run. reaches the time limit set by your hosting provider. To prevent the abuse of server resources time limit is very important.
This article will show you how to fix the fatal error: maximum execution time exceeded in WordPress.
Why ‘Maximum Execution Time Exceeded’ Error Occurs?
WordPress core is coded in the PHP programming language. To protect web servers from being abuse, there is a time restriction set for a script to how long time it will run.
The actual time restriction different for different hosting companies. However, usually, the time for the maximum execution is set between 30 – 120 seconds because that’s enough for a good script to run.
When a script reaches the maximum execution time limit, an error is thrown by the servers that the maximum execution time is exceeded.
There are two methods to solve this error.
Let’s start Fixing Execution Time Exceeded Error
Although Maximum Execution Time Exceeded error is shown as a ‘fatal error,’. It is the most common WordPress error that many developers face. But you can easily resolve this by changing the time limit.
Caution: We strongly recommend not to change this setting permanently. change it for a script, when it runs successfully revert back it to your hosting server’s original limit.
If this error is caused by a plugin, simply go to your installed plugins menu. There you can simply deactivate or delete the plugin that is causing the error.
However, if the plugin is important and you don’t want to deactivate It, then you can fix this cause that triggered the error.
You will need to manually edit your .htaccess file to fix this issue by adding a line of code in the .htaccess file.
Simply go to your website cPanel and look for the file manager there.
Your .htaccess file is located in the main directory of your site. Simply go to file manager and look for the “Public_html” directory. Navigate to it and you will find a file with the name .htaccess.
Right-click on the .htaccess file and choose edit. the file will be opened in a text editor. Simply add the following line of code to the end of the file.
php_value max_execution_time 300
This will increase the execution time to 6 minutes. Now refresh site and see if the error is resolved or not. If still this error happens. try to increase it more and more.
The second method is to change your php.ini file.
The php.ini file is the configuration file that defines settings for your PHP on the server. Many hosting platforms, you may not be able to find it inside your website directory.
If you can not file that file simply create a new one. Go to the root directory of your website. Here create a new file with the name of php.ini and add the following line of code and save it.
max_execution_time = 60
If you are running on localhost and using XAMPP, then you can navigate to your xampp installation directory, usually in your C:/Xammp folder. Now locate the PHP folder and find the php.ini file. Right-click on it and select edit.
php.ini will be opened in the default text editor. Search for the ‘Maximum Execution Time’ and change the Execution time there, as shown in the below image.
Now save this file and check the site, hopefully, the error will be resolved. If not then simply comment below so we can help you.