In this article we will show you how to change PHP time limit WordPress to fix this “Fatal error: Maximum execution time of 30 seconds exceeded” error.
This issue typically arises when a PHP code in WordPress runs slowly and exceeds the allotted time limit established by your WordPress hosting server. The time restriction is crucial since it helps stop the exploitation of server resources.
What Is The PHP Time Limit?
The PHP Time Limit determines how long an action will take on your site before clocking out. An operation will produce a fatal error when it exceeds the time limit set, as seen below:
On the majority of hosts, the PHP Time Limit’s default setting is 30 seconds.
Why Does the Maximum Execution Time Error Occur?
PHP is primarily used in the coding of WordPress. There is a time restriction specified for how long a PHP script may execute in order to safeguard web servers against misuse.
Although the exact time restriction varies across hosting providers, it is often set between 30 and 60 seconds because that is typically long enough for a reliable PHP script to operate.
Get exclusive access to all things tech-savvy, and be the first to receive
the latest updates directly in your inbox.
The error message “maximum execution time exceeded” appears when a script exceeds its allotted execution time.
Each WordPress site has a limit on the amount of time it can take to execute server requests. Its goal is to reduce server misuse. This restriction checks each PHP script currently active on your website and disables those that exceed the time limit.
WordPress site files mostly employ PHP, thus it’s critical to monitor PHP scripts to detect whether they run for an excessively lengthy time or consume an excessive amount of server resources. It’s not unusual for malicious assaults to use endless PHP scripts to slow down the website.
In addition, certain WordPress plugins, themes, or other components might tax server resources if they take too long to load. This error message appears to be generated by plugins more frequently than by other components, which is probably due to the fact that WordPress users install plugins more frequently than they do themes or edit code. Additionally, because plugins come from a variety of developers, it might be challenging to identify the excellent ones that are supported by reliable code and regular updates.
There is a maximum execution time restriction since there aren’t many reasons for a PHP script to execute for a long period of time, regardless of the reason. This cap is often established at the server level by your hosting provider.
Contact your provider
The procedure for increasing the PHP Time Limit is complicated and varies from host to host. Therefore, it is usually preferable to have it done by a specialist. Simply contact CyberPanel support team, and they will be happy to assist you.
How to increase PHP time limit using the CyberPanel Dashboard
Go to your CyberPanel dashboard
Click on PHP -> Edit PHP Configs from the left hand side menu
Select your PHP and set your max_execution_time to 300 or whatever limit you need it to be
Click on Save Changes.
How to increase PHP time limit using wp-config.php?
The most popular technique is this one. You need to edit the wp-config.php
file on your WordPress site as it located in your WordPress site’s file manager.
Go to your CyberPanel dashboard
Click on WordPress -> List WordPress from the left hand side menu. This will take you to the List of WordPress Sites page
Click on your site from this list
This is your WordPress Manager for your WordPress site. Click on File Manager from here.
Right click on wp-config.php and click on Edit with Code Mirror
After it says “That’s all, stop editing! Happy publishing“, paste the following code
set_time_limit (300);
Click on Save Changes. This code instructs the server to set the PHP timeout to 300 seconds
How to increase PHP time limit using .htaccess?
This can also be done via .htaccess if you aren’t comfortable with wp-config.php.
Go to your CyberPanel dashboard
Click on WordPress -> List WordPress from the left hand side menu. This will take you to the List of WordPress Sites page
Click on your site from this list
This is your WordPress Manager for your WordPress site. Click on File Manager from here.
Right click on .htaccess and click on Edit with Code Mirror
At the very end of the file, enter the following code
max_execution 300
Click on Save Changes and Refresh your site.
Conclusion
Experiencing errors because of the short PHP time restriction might be annoying. The time limit is essential because it prevents the overuse of server resources. The solutions discussed above will enable you to modify the PHP time limit.