Troubleshooting

Maximum execution time of X seconds exceeded in x.php

Reviewed on 3 min read errores php php

The message:

Maximum execution time of X seconds exceeded in x.php

confirms that the process reached PHP's max_execution_time limit. The file and line show where the timer ran out, but do not by themselves prove which component used up the time.

Reproduce the exact operation and check the application and PHP logs first. If it is a reproducible slow request, use PHP X-Ray to check whether the time is concentrated in an SQL query, an external call, a function or a specific component. Also rule out loops, retries and unexpected data volumes.

Only raise the limit when the operation is legitimate, bounded and reasonably needs more time. Check which PHP version runs the path, go to cPanel > Select PHP Version > Options and set max_execution_time to the lowest finite value that lets the test complete. The change affects every website using that version.

Do not keep increasing the value until the error disappears, and do not set it to unlimited. PHP uses this timer as protection against faulty scripts. In addition, the web server and other components may apply their own timeouts.

After the test, restore the previous value. If the process exhausts a reasonable value again, fix the operation or the identified component instead of raising it further. If you suspect a resource limit, check the recorded CPU, memory, entry process, IO or process faults: high usage without a limit fault does not prove that the limit ended or slowed down the request.

PHP time and total request time

On Unix systems, max_execution_time does not necessarily measure all the wall-clock time elapsed: waits for certain external operations may not count towards it. On Windows it behaves differently. That is why the total time seen in the browser cannot be compared directly with that limit. See the PHP definition.

For imports or long jobs, consider splitting the work into batches or running it as a compatible CLI task, with error handling and progress tracking. CLI may also have its own limits and does not avoid hosting quotas. Before retrying an interrupted operation, check which data was already saved so you do not duplicate it.

You may also find useful

Something wrong or out of date? Tell us and we will review it.