PHP Fatal error: Maximum execution time of 30 seconds exceeded
The script ran longer than max_execution_time and PHP stopped it.
Seen on:
PHP
Meaning
PHP limits CPU time per request (default 30s; unlimited on CLI). Long imports, slow external calls or infinite loops hit it.
Common causes
- Slow database queries
- Synchronous calls to slow external APIs
- Large imports/exports in a web request
- Infinite loops
⚡ Quick fix
- Move long tasks to CLI/cron or a queue
- Optimize the slow query/API call
set_time_limit(120)for known-long scripts- Check the FPM/proxy timeouts too, or you’ll get a 504 instead
Detailed fix by platform
PHP
- php.ini:
max_execution_time = 120. For FPM alsorequest_terminate_timeoutin the pool config.
How to diagnose
- Location — Which line was running when it stopped?
- Bottleneck — DB, network or loop?
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026