Troubleshooting
Maximum execution time of X seconds exceeded in x.php
Long operations, such as exporting or importing data, regenerating thumbnails or restoring a backup with a plugin, can end with this error:
Fatal error: Maximum execution time of 30 seconds exceeded in /home/usuario/public_html/x.php on line 123
It means the script has exceeded the maximum time PHP allows it to run (max_execution_time). The solution is to increase that time.
Option 1: in .htaccess
This only affects the website where you add it. Open the .htaccess in public_html or in the application's folder from cPanel's File Manager (if it does not exist, create an empty file with that name) and add at the top:
php_value max_execution_time 300
300 is the number of seconds (5 minutes). Save and repeat the operation.
Option 2: in Select PHP Version
- In cPanel, go to Select PHP Version and open the Options tab.
- Change max_execution_time to
300.
The change is saved immediately and affects all the websites in the account that use that PHP version.
If it still appears
- Raise the value gradually (600, 900). If an operation needs more than 15 minutes, it is not a good idea to keep raising it: split it into smaller parts (export by date ranges, import in several files) or run it via SSH, where there is no PHP time limit.
- If the error appears on a normal page of the website, not in a long task, the problem is not the limit but something that hangs: a slow query, a call to an external service that does not respond or a plugin loop. PHP X-Ray tells you where that request's time goes.
When you finish the long operation, you can go back to the previous value so that a stuck script does not use resources for minutes.
You may also find useful
- PHP error when using require_once, require, include_once or include Interpret the full message when PHP cannot open a file and check the path, permissions and restricti...
- Debug errors in PHP applications or files Diagnose a blank screen or a 500 error by reproducing the failure and checking the most specific log...
- Enable PHP error logging and display Save PHP errors to an error_log file or show them on screen to find the cause of a blank page or a 5...
- Enable PHP error logging from the .htaccess file Configure .htaccess to temporarily log PHP errors outside public_html, without revealing them on scr...
Something wrong or out of date? Tell us and we will review it.