What the message looks like
PHP Fatal error: Maximum execution time of 30 seconds exceeded in /var/www/html/wp-admin/includes/class-wp-upgrader.php on line 214Common causes
- A slow database query, a slow external API or a large import or export.
- The task is simply bigger than the default limit: updates, backups, image batches.
- A loop that never ends or waits for something that does not happen.
- The limit was raised for PHP, but nginx or a proxy still cuts the request earlier (then you see 504 instead).
- The command line has no limit (default 0), so the problem only shows in the browser.
Check
- What limit does PHP-FPM use?
grep -rn 'max_execution_time' /etc/php/*/fpm/ - Check the active value from the web server's point of view
php-fpm8.3 -i | grep -i max_execution_time - Is the web server timeout shorter?
nginx -T 2>/dev/null | grep -E 'fastcgi_read_timeout|proxy_read_timeout'
Fix
- Find the slow part (query, API call) and speed it up. That is the real fix.
- Raise the limit where needed:
max_execution_time = 120in the FPMphp.ini, orphp_admin_value[max_execution_time] = 120in the pool, then reload PHP-FPM. - Raise
fastcgi_read_timeoutin nginx to match, otherwise users get a 504 first. - Run long tasks as a cron job, queue worker or CLI command instead of in a web request.
- In your own code, call
set_time_limit()only for the one script that needs it.
Typical scenario
You update ten WordPress plugins at once on a small VPS. After 30 seconds PHP stops with "Maximum execution time exceeded" in class-wp-upgrader.php, and the site then permanently shows "Briefly unavailable for scheduled maintenance". WordPress created the .maintenance file in the web root and, because of the abort, never removed it. First check whether that file exists and delete it if no update is running any more.
FAQ
Why do I still get a 504 after raising max_execution_time?
nginx has its own limit, 60 seconds by default. See upstream timed out (110).
Is a very high limit safe?
A long limit lets one stuck request block a worker for a long time. Keep it as low as the real task allows.
Does time spent on database queries and sleep() count?
Not on Linux. max_execution_time only measures the time the script itself is working. Waiting in system calls, database queries or network streams is not counted. A script that mostly waits can therefore run much longer than 30 seconds.
Can I change the limit from inside the script?
Yes, with set_time_limit(120) or ini_set('max_execution_time', '120'); the counter restarts. It does not work if the function is listed in disable_functions or the host enforces the limit, and it does nothing against nginx timeouts.
How do I prevent the error permanently for large imports?
Split the work into small batches with a progress indicator, or run it from cron, a queue worker or WP-CLI, where no web server timeout applies. A higher limit only postpones the problem once the data keeps growing.