If you use an Apache hosting or local servers like XAMPP or WAMP for your website development, you must have encountered this error message “Fatal Error: Maximum execution time of 30 seconds exceeded on line…” while trying to run a code, import demo data or upload a plugin (on WordPress)
Why Fatal Error: Maximum Execution Time Exceeded Occurs
Every PHP code or script has a number of time it is expected to run for security reasons and when it has reached its limit you experience this error message. This is why it is recommended to set the value to a very high number so as to ensure that it doesn’t occur.
How to Fix Fatal Error: Maximum Execution Time Exceeded
For a live server, there are two different ways to fix this:
1. Editing the .Htaccess file
To edit the .Htaccess file, go to your Cpanel and check the option for show hidden files (On the settings section of the Cpanel)
Next, add this code:
php_value max_execution_time 300
To your .htaccess file and save. Reload your website and it should be working properly. If you still get the error message after that, increase it further to 900 or above and this should stop it from happening again.
2. Using a Plugin
If you don’t want to edit the files on your Cpanel because you may not be able to manage it, you can go for this method by downloading the WP Maximum Execution Time Exceeded Plugin and setting the value to your desired figure and this should get it running just like above.
How to Fix Fatal Error: Maximum Execution Time Exceeded on XAMPP
When developing a website offline, you will also experience this error message. The same code that is used for a live server is what is needed to fix it on XAMPP as well but this time around in a different file. To fix this, go to your XAMPP control Panel, on the Apache section, click on Config as shown below
Now, locate Php.ini and click on it. While on the page, use CTRL+F to look for max_execution_time
Increase the value to your desired number (600,900 or above) and save. Restart the Apache again and reload your website. It should be working fine.