“Maximum execution time exceeded” PHP error

Why PHP stops long-running scripts, how to work within the limit with batching and cron, and when raising max_execution_time is appropriate.

TroubleshootingIntermediate2 min readUpdated

Does this match what you’re seeing?

  • Log shows ‘Maximum execution time of 30 seconds exceeded’
  • Imports or backups stop partway
  • A page loads for a long time and then errors
PHP Fatal error: Maximum execution time of 30 seconds exceeded in /home/user/domains/yourdomain.co.uk/public_html/import.php on line 88

PHP stops scripts that run longer than max_execution_time, so a stuck script can’t tie up the server indefinitely.

Why long web requests are a bad idea anyway

Even with a higher limit, browsers, proxies and CDNs often give up on a request after a minute or two. Long jobs are better done in smaller pieces.

Better approaches

Raising the limit

If a job genuinely needs a bit longer, check whether max_execution_time is adjustable. Changing PHP settings: memory_limit, upload size and execution time In a script, you can request more time where allowed:

<?php set_time_limit(120);

Server-level ceilings still apply.

Everything in this guide works on Traxio’s PHP hosting, which is free for 30 days and £0.99 a month after that.

Popular

Tip: press / to search from any pageSee all results