PHP

Maximum execution time exceeded (PHP)

The script ran longer than max_execution_time and PHP stopped it.

What it looks like

PHP Fatal error:  Maximum execution time of 30 seconds exceeded in /var/www/app/import.php on line 54

What does "Maximum execution time exceeded (PHP)" mean?

A fatal error raised when a web request runs longer than max_execution_time (30 seconds by default). The line named is simply where the script happened to be when time ran out, which may be inside a loop or a slow call.

What causes "Maximum execution time exceeded (PHP)"?

  • A slow query or external API call.
  • An infinite/large loop.
  • Heavy processing in a web request.

How do I confirm the cause?

  1. Check what that line does — a database query, an HTTP request to another service, or a loop over many items.
  2. Time the slow step on its own (microtime(true) before and after) to confirm where the seconds go.
  3. Check whether a slow external API or a missing database index is the real delay.

How do I fix "Maximum execution time exceeded (PHP)"?

  • Profile and speed up the slow part.
  • Move long work to a queue/cron job.
  • Raise max_execution_time only for legitimately long CLI tasks.

How do I stop it happening again?

  • Do long jobs (imports, exports, sending many emails) in a queue worker or cron job, not during a page request.
  • Put timeouts on outgoing HTTP calls so one slow service cannot hold a request for the whole limit.
Got a different error? Paste it into the Explain This Error tool → Identifies the family and the fix — runs locally, nothing uploaded.

Related errors