This week I tried to update a theme on a WordPress site and ran into the error Fatal Error: Maximum Execution Time Exceeded in WordPress. The fix in this case is simple, but can be frustrating for beginners. Here is how to fix the Maximum Execution Time Exceeded error in WordPress.
WordPress is largely built on PHP, and to protect servers there is a limit on how long a PHP script can run. Some hosting providers allow longer execution time and others limit it more strictly. When the script hits the limit, you get this message.
How to fix it?
The fix depends on how your server runs PHP. To check, go to Tools > Site Health > Info > Server and look at the PHP SAPI row.
If it shows apache2handler, PHP runs as an Apache module. Connect to your server via FTP, find the .htaccess file in the same directory as wp-content and wp-admin, and add:
<IfModule mod_php.c>
php_value max_execution_time 300
</IfModule>
This sets execution time to 300 seconds (5 minutes); you can change it as needed. For reference, the Avada theme version 3.8 requires at least 180 seconds to work properly.
On PHP 8 the module is named
mod_php.c. Older guides usemod_php7.c, which only matches PHP 7, so on PHP 8 the setting inside it is silently skipped. Don’t drop theIfModulewrapper either: without it, a server that doesn’t run PHP as an Apache module returns a 500 error.
If it shows fpm-fcgi or cgi-fcgi (common on modern hosting), .htaccess can’t change PHP settings. Instead, create a .user.ini file in the same directory and add:
max_execution_time = 300
PHP rereads this file every 5 minutes by default, so the new limit can take up to 5 minutes to apply. If neither method works, ask your hosting provider to raise the limit.
For more wp-config.php tweaks, see Optimize WordPress Configuration via wp-config.php.