Fix “Maximum execution time of 30 seconds exceeded” in WordPress
If you encounter the error “Maximum execution time of 30 seconds exceeded” in WordPress, it means a PHP script is taking too long to run and is being stopped by the server. This often happens during plugin updates, backups, or importing large files. The quick fix is to increase the PHP maximum execution time limit so scripts have more time to complete.
Quick Fix
- Access your WordPress root directory via FTP or file manager.
- Edit or create a
php.ini
or.user.ini
file. - Add or update this line to increase the time limit (e.g., 300 seconds):
max_execution_time = 300
- If you cannot edit
php.ini
, add this line to yourwp-config.php
file instead:
set_time_limit(300);
- Save changes and test your site or process again.
Why This Happens
PHP scripts have a maximum execution time to prevent poorly written code from running indefinitely and overloading the server. The default is often set to 30 seconds on many shared hosting environments. When WordPress or a plugin runs a process that takes longer—like importing large data, running backups, or complex queries—the script hits this limit and stops, causing the error.
Increasing the max_execution_time
gives scripts more time to finish. However, setting it too high may affect server performance, so adjust carefully based on your needs.
Step-by-step Guide to Fix the Error
1. Using php.ini or .user.ini (Recommended)
This method works if you have access to your PHP configuration files.
- Connect to your server using FTP or your hosting control panel file manager.
- Navigate to your WordPress root directory (where
wp-config.php
is located). - Look for a
php.ini
or.user.ini
file. If none exists, create a new file namedphp.ini
or.user.ini
. - Edit the file and add or update the following line:
max_execution_time = 300
This sets the maximum execution time to 300 seconds (5 minutes).
- Save the file and upload it back to the server if using FTP.
- Restart your web server if you have control over it (not always possible on shared hosting).
- Test your WordPress site or the process that caused the error.
2. Using wp-config.php
If you cannot access or modify php.ini
, you can try increasing the time limit via WordPress configuration.
- Access your WordPress root directory.
- Edit the
wp-config.php
file. - Add the following line near the top, just after the opening
<?php
tag:
set_time_limit(300);
- Save the file and upload it back.
- Test your site or process again.
3. For Nginx Servers
Nginx does not use php.ini
directly but you can increase PHP-FPM timeout settings.
- Access your server via SSH.
- Edit your PHP-FPM pool configuration file, usually located at:
/etc/php/7.x/fpm/pool.d/www.conf
(Replace 7.x
with your PHP version.)
- Find and update these values:
request_terminate_timeout = 300s
max_execution_time = 300
- Save the file.
- Restart PHP-FPM and Nginx:
sudo systemctl restart php7.x-fpm
sudo systemctl restart nginx
Replace php7.x-fpm
with your PHP-FPM service name.
4. For Apache Servers
Apache usually respects php.ini
or .htaccess
overrides.
- Access your WordPress root directory.
- Edit or create a
.htaccess
file. - Add this line:
php_value max_execution_time 300
- Save and upload the file.
- Restart Apache if you have server access:
sudo systemctl restart apache2
On shared hosting, this restart is handled automatically.
5. Using cPanel
- Log in to your cPanel dashboard.
- Go to Select PHP Version or MultiPHP INI Editor.
- Find the
max_execution_time
setting. - Increase the value to 300 or higher.
- Save changes.
6. Using Plesk
- Log in to your Plesk panel.
- Go to Domains > select your domain > PHP Settings.
- Find
max_execution_time
and increase it. - Save changes.
Works on
Environment | Applicable Fix |
---|---|
Apache (shared/dedicated) | .htaccess, php.ini, wp-config.php |
Nginx with PHP-FPM | php.ini, PHP-FPM config, wp-config.php |
cPanel Hosting
Fixes & Errors
Tags:PHP.ini, Timeout, WordPress, WP-Config
|