Skip to content

WordPress "Maximum execution time exceeded" on cPanel

Handling the Maximum execution time exceeded fatal on WordPress on cPanel — when to raise the timeout, when to fix the code, and what changes with PHP-FPM vs CGI.

“Maximum execution time of 30 seconds exceeded” is PHP saying a single request ran longer than the configured ceiling. Raising the ceiling is reasonable for some work. For other work it’s hiding the problem — the code is slow because it’s doing something inefficient, and giving it more time means slow pages forever instead of broken pages now.

What’s happening

PHP’s max_execution_time kills any request running longer than the configured value. On cPanel, the default is usually 30 seconds, sometimes 60. Web requests should rarely take more than a few seconds. Long-running tasks (imports, exports, large media operations) should happen via cron, CLI, or queued background processes — not in a web request that holds an HTTP connection open while a visitor watches a spinner.

How to verify

php -i | grep max_execution_time
grep -i 'maximum execution time' ~/public_html/error_log | tail

The error log tells you what URL was running when it timed out:

[Mon May 19 10:42:15] PHP Fatal error: Maximum execution time of 30 seconds exceeded in /home/user/public_html/wp-content/plugins/example/heavy.php on line 218

That file:line is the actual hot spot.

The fix

  1. Decide whether to raise the limit or fix the code:

    • Raise it for legitimate admin operations: bulk plugin updates, theme imports, one-off content migration tools. These rarely run, they need time, no end user is waiting.
    • Fix the code for anything that affects normal page loads — a slow product listing query, a synchronous external API call in the page render, an N+1 query bug.
  2. To raise, edit cPanel > MultiPHP INI Editor > select account > max_execution_time to a more generous value (300 for admin tasks). Save.

  3. For specific admin pages, you can also raise dynamically with a mu-plugin:

    add_action( 'admin_init', function() {
        if ( isset( $_GET['page'] ) && $_GET['page'] === 'heavy-import' ) {
            @set_time_limit( 600 );
        }
    } );
  4. PHP-FPM has its own request timeout (request_terminate_timeout) that overrides max_execution_time. On cPanel running PHP-FPM, the FPM pool’s timeout is the real ceiling. Check /etc/php-fpm.d/<pool>.conf or, more typically, the cPanel-managed equivalent. Raise both if needed.

  5. LiteSpeed has its own ConnTimeout and request limits that can clip long requests at the web server level even when PHP would be happy to continue. Check lsws/conf/httpd_config.conf if your timeouts coincide with a LiteSpeed-imposed ceiling.

  6. For genuinely long work, move it off the web request. Three patterns:

    • WP-CLI: wp tool heavy-thing from SSH. No web timeout.
    • WP-Cron: schedule the work as a WP-Cron event, triggered by system cron. Each iteration does a chunk; many short iterations replace one long one.
    • Action Scheduler (Woo and others ship with it): queue work as actions, processed in the background.
  7. If the long requests are inbound API calls (REST API, webhooks), consider returning a 202 Accepted immediately and processing the payload asynchronously. The caller gets a quick response, your server does the work without an active HTTP connection.

For environments where this kind of optimization is part of the operating posture, Stack Harbor handles it under enterprise WordPress hosting.