You click Update, run an import or regenerate thumbnails, and WordPress stops with a white page or a line like this:
PHP Fatal error: Maximum execution time of 30 seconds exceeded in /home/user/public_html/wp-includes/class-wpdb.php on line 2351
PHP killed the request because it ran longer than max_execution_time allows. The default is 30 seconds. Plugin updates, WooCommerce imports, backup plugins, page builders saving huge pages and image processing are the usual places where people hit it.
The fix is to raise the limit for the request that needs it, or better, move the long job to WP-CLI where there is no limit. Both are below.
Don’t blame the file in the error message
The path in the error is only where PHP happened to be when the clock ran out. If it says wp-includes/class-wpdb.php or wp-includes/formatting.php, core is not broken. Something else (a plugin loop, a big import, a resize) used up the 30 seconds and core was just the code running at second 30.
So write down what you were doing when it happened. That action is the real cause, and it tells you whether raising the limit is enough or whether you need to find a slow plugin.
To see the current limit, go to Tools → Site Health → Info → Server and look at PHP time limit. That is the value your web requests run with.
💡 Don’t check it with wp eval or php -i in the terminal. On the command line PHP’s default is 0 (no limit), so you will see a different number than your website uses.
Step 1. Back up the files you will edit
Every fix below touches a config file. Copy it before you change it, so you can roll back in seconds if the site returns a 500 error:
cp wp-config.php wp-config.php.bak
cp .htaccess .htaccess.bak
Step 2. Raise max_execution_time in php.ini or .user.ini
This is the clean fix. If you have access to the PHP configuration (VPS, or a hosting panel with a php.ini editor), set:
max_execution_time = 300
On shared hosting with PHP-FPM you usually can’t edit the main php.ini, but you can create a .user.ini file in the WordPress root (next to wp-config.php) with the same line. PHP rereads .user.ini files on a timer (5 minutes by default), so give it a few minutes before you test.
On your own server, restart PHP-FPM after editing php.ini. The service name depends on the version, for example:
sudo systemctl restart php8.3-fpm
Then reload Site Health. PHP time limit should now show 300. If it still shows 30, you edited a php.ini that this PHP version doesn’t load. Run php --ini for the CLI side, or check the “Loaded Configuration File” line in a phpinfo() page for the web side.
Step 3. Use .htaccess only if PHP runs as an Apache module
Older guides tell you to add this to .htaccess:
<IfModule mod_php.c>
php_value max_execution_time 300
</IfModule>
php_value only works with mod_php. Most hosts now run PHP-FPM, and there a bare php_value line causes a 500 Internal Server Error. The <IfModule> wrapper keeps it harmless, but if Site Health doesn’t change, go back to Step 2.
Step 4. Set the limit from wp-config.php
max_execution_time is an INI_ALL setting, so PHP lets a script change it at runtime. If you can’t touch php.ini at all, add this to wp-config.php above the /* That's all, stop editing! */ line:
/* Give slow requests up to 5 minutes. */
if ( function_exists( 'set_time_limit' ) ) {
set_time_limit( 300 );
}

Per the PHP manual, set_time_limit() restarts the timeout counter from zero, so this gives every request 300 seconds from the moment wp-config.php loads. WordPress core does the same thing itself: update_core() calls set_time_limit( 300 ) before it copies the new files.
The function_exists() check matters. Some hosts put set_time_limit in disable_functions, and calling it there would only add a warning. If the host disabled it, this step does nothing and you need Step 2 or a support ticket.
I treat this as a temporary fix. It raises the limit for every request on the site, including the ones bots send, so remove it once the import or update is done.
Step 5. Raise the web server timeout too
PHP is not the only clock. If you raise PHP to 300 seconds and now get a 504 Gateway Timeout after about a minute, the web server gave up first. In nginx, fastcgi_read_timeout defaults to 60 seconds (nginx docs). Raise it in the PHP location block:
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:/run/php/php8.3-fpm.sock;
fastcgi_read_timeout 300s;
}
Test and reload with sudo nginx -t && sudo systemctl reload nginx. On Apache the matching directive is Timeout, which the PHP manual lists as 300 seconds by default. Also check request_terminate_timeout in your PHP-FPM pool file, because when it is set it kills the worker no matter what max_execution_time says.
Run long jobs with WP-CLI instead
The best fix for a job that takes minutes is to not run it in the browser at all. PHP on the command line has no execution time limit by default, and there is no nginx or Apache in the way:
wp core update
wp plugin update --all
wp db import backup.sql
wp media regenerate --yes
wp action-scheduler run
Each command prints its progress and ends with a Success: line. If one stops with an error, it is a real error from the plugin or the data, not a timeout, which makes it much easier to debug. wp action-scheduler run needs WooCommerce or another plugin that ships Action Scheduler.
If WooCommerce or another plugin keeps timing out on background tasks, the queue often piles up too. My post on the Action Scheduler past-due actions notice shows how to work through it from the terminal.
Find out why a normal page needs 30 seconds
An import that takes 2 minutes is normal. A normal front-end page or wp-admin screen that hits 30 seconds is not, and raising the limit only hides the problem.
On Linux this limit usually counts CPU work, not waiting. The PHP manual says that on non-Windows systems, system calls and stream operations don’t count toward it, and set_time_limit() adds database queries to that list. So a slow external API alone rarely triggers this error. Something is looping, recursing or crunching data (ZTS builds since PHP 8.3 can count I/O wait too, but most hosting runs non-ZTS PHP).
To find it, turn on logging in wp-config.php and repeat the action:
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );

Then open wp-content/debug.log. Warnings logged just before the fatal error often point to the plugin, and the path in the fatal error itself sometimes points into wp-content/plugins/ directly. If the log file doesn’t show up, see debug.log not created in WordPress.
If the log doesn’t name a plugin, deactivate plugins one at a time and repeat the action after each one. WP-CLI makes this fast:
wp plugin list --status=active
wp plugin deactivate suspect-plugin-slug
# repeat the slow action in the browser, then:
wp plugin activate suspect-plugin-slug
💡 A timeout that started right after an update, with WordPress showing “There has been a critical error on this website”, is the same fatal error behind the generic screen. The recovery-mode email names the plugin; my post on the critical error message walks through it.
Changing the limit in OpenPanel vs cPanel
In cPanel you usually change this in MultiPHP INI Editor. In OpenPanel it is under PHP → Options: pick the PHP version, edit max_execution_time and click Save changes. As of 2026-11-30 the docs say the value is written to that version’s php.ini, the PHP container restarts, and the change applies to all domains on that PHP version. That is a difference from setting it for one site at a time, so keep it in mind if you host several sites. If the admin enabled it, there is also a raw PHP.INI Editor for the same file.
TL;DR: “Maximum execution time of 30 seconds exceeded” means a request ran past PHP’s max_execution_time. Raise it to 300 in php.ini or .user.ini (or with set_time_limit( 300 ) in wp-config.php as a stopgap), raise fastcgi_read_timeout if a 504 follows, and run big updates and imports with WP-CLI, which has no limit. If an ordinary page needs 30 seconds, find the plugin instead of raising the number.

