php
execution
ai_generated
true
Fatal error: Maximum execution time of 30 seconds exceeded
ID: php/max-execution-time
87%Fix Rate
89%Confidence
95Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 83 | active | — | — | — |
Root Cause
Maximum execution time errors occur when a PHP script exceeds the configured max_execution_time. This is commonly caused by slow database queries, external API calls without timeouts, infinite loops, or processing very large files synchronously.
genericWorkarounds
-
92% success Move long-running tasks to background queue workers
Use a queue system (Laravel Queue, Symfony Messenger, or a simple Redis/RabbitMQ consumer) to offload long-running tasks. The web request dispatches the job and returns immediately. The queue worker processes it without web timeout constraints.
-
86% success Optimize the slow code path with profiling and add appropriate timeouts to external calls
Use Xdebug profiler or Blackfire to identify bottlenecks. Add database indexes for slow queries. Set timeouts on cURL/Guzzle HTTP requests (e.g., 'timeout' => 10). Use LIMIT on database queries processing large result sets.
Dead Ends
Common approaches that don't work:
-
Setting set_time_limit(0) or max_execution_time=0 globally
78% fail
Disabling the execution time limit globally allows runaway scripts to hang indefinitely, consuming server resources. In web contexts this can exhaust all PHP-FPM workers and bring down the application.
-
Increasing max_execution_time without profiling the slow code path
68% fail
Raising the limit without understanding why the script is slow only delays the problem. As data grows, the script will exceed the new limit as well. The underlying performance issue remains unresolved.
Error Chain
Leads to:
Preceded by:
Frequently confused with: