How to fix "Fatal error: Maximum execution time of 30 seconds exceeded"

How to fix "Fatal error: Maximum execution time of 30 seconds exceeded"

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

How to fix "Fatal error: Maximum execution time of 30 seconds exceeded"

When you attempt to install a heavy plugin like WooCommerce, PHP often hits its default execution time limit before the installation process finishes. The error message Fatal error: Maximum execution time of 30 seconds exceeded appearing in wp-admin/includes/class-wp-filesystem-direct.php indicates that the script running inside the WordPress admin panel took longer than the allowed window.

This is a configuration issue, not a code bug in your theme or plugin. The server is simply cutting off the process to prevent it from hanging indefinitely. While plugins like "WP Maximum Execution Time Exceeded" exist to handle this dynamically, they often fail during the initial installation phase because the script that installs the plugin runs outside the normal request cycle where those plugins are active. You need to adjust the limits at the server or application level before starting the installation.

Adjusting Limits in php.ini

The most robust solution involves editing the php.ini file, which controls the core PHP configuration. Look for the max_execution_time directive and change it from 30 to a higher value, such as 60 or 120.

max_execution_time = 600
memory_limit = 256M

You must restart Apache or Nginx for these changes to take effect. This approach ensures that any long-running script, whether triggered by a user request or an internal process like plugin installation, has enough time to complete. However, be aware that setting these values too high on shared hosting or low-resource environments can lead to server instability if a rogue script enters an infinite loop.

Modifying wp-config.php

If you cannot access the php.ini file or do not have permission to restart the web server, you can bypass the limit directly within your WordPress installation using the wp-config.php file. This method is preferred because it isolates the change to your specific site without affecting other sites on a shared host.

Add the following line to your wp-config.php file:

set_time_limit(60);
ini_set('max_execution_time', 60);
ini_set('memory_limit', '256M');

Place this code near the top of the file, after the <?php opening tag but before any other configuration constants. This forces PHP to ignore the default limit set in php.ini. The trade-off here is minimal; you are only affecting your specific WordPress instance. However, if you have a script that genuinely hangs for hours due to poor coding practices, this will keep it running until the Apache worker timeout occurs instead of the PHP limit.

Using .htaccess for Apache Servers

If your server runs on Apache and does not allow direct access to php.ini, you can override these settings using an .htaccess file placed in your WordPress root directory. This is a common requirement when dealing with XAMPP or shared hosting environments where file permissions are restricted.

php_value max_execution_time 600
php_value memory_limit 256M

Note that .htaccess overrides only work if AllowOverride All is enabled in your Apache virtual host configuration. If this setting is disabled, the directives will be ignored regardless of what you write in the file. Always test these changes in a staging environment first. A misconfigured limit can cause legitimate requests to timeout unexpectedly if the server load spikes during peak hours.

Why Plugin Overrides Often Fail

You mentioned installing the "WP Maximum Execution Time Exceeded" plugin and still encountering errors. This is expected behavior. When you click "Install Plugin," WordPress executes a script that installs files via WP_Filesystem_Direct. If the installation takes longer than 30 seconds, PHP terminates the process immediately. At that exact moment, your custom timeout-extension plugin has not yet loaded because the request was killed before it could initialize. To resolve this, you must raise the limit before invoking the installation routine, which is why editing php.ini, wp-config.php, or .htaccess is necessary.

Our network