Maximum execution time 🐘 PHP

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

  1. Move long tasks to CLI/cron or a queue
  2. Optimize the slow query/API call
  3. set_time_limit(120) for known-long scripts
  4. Check the FPM/proxy timeouts too, or you’ll get a 504 instead

Detailed fix by platform

PHP

  1. php.ini: max_execution_time = 120. For FPM also request_terminate_timeout in the pool config.

How to diagnose

  1. Location — Which line was running when it stopped?
  2. 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.