Test your skills on our all Hosting services and get 15% off!

Use code at checkout:

Skills
21.10.2024

How to Fix the max_execution_time Error in WordPress

The max_execution_time error in WordPress typically occurs when a script takes too long to run, exceeding the time limit set by your server’s configuration. This limit is designed to prevent poorly written scripts from using excessive server resources. However, if you’re performing actions like installing plugins, importing large files, or running updates, you might encounter this error.

Here’s how you can fix the max_execution_time error in WordPress by increasing the execution time limit.


Method 1: Modify the php.ini File

The php.ini file is the default configuration file for running PHP scripts. If you have access to this file, you can increase the maximum execution time.

Step 1: Access Your Hosting Control Panel or Server

  1. Log in to your hosting account and open the File Manager from cPanel, or connect to your server via FTP or SSH using a client like FileZilla.
  2. Navigate to your website’s root directory (usually called public_html).

Step 2: Locate or Create the php.ini File

  1. Look for a file named php.ini in your root directory. If it doesn’t exist, you can create one.
    • In cPanel, go to File Manager > public_html and click on + File. Name the file php.ini.
  2. If the file already exists, open it for editing.

Step 3: Increase the max_execution_time

  1. Add or update the following line in your php.ini file:
    max_execution_time = 300

    This sets the maximum execution time to 300 seconds (5 minutes). You can increase this value as needed.

  2. Save the changes and exit the file editor.

Step 4: Restart Your Web Server (If Needed)

Some hosting environments require you to restart the web server for the changes to take effect. Contact your hosting provider if you’re unsure.


Method 2: Edit the .htaccess File

If you don’t have access to the php.ini file, you can try editing your .htaccess file, which controls various server configurations.

Step 1: Access the .htaccess File

  1. In your website’s root directory (public_html), locate the .htaccess file.
    • If you don’t see it, it may be hidden. In cPanel, click on Settings in the top-right corner of File Manager and check the Show Hidden Files (dotfiles) option.
  2. Right-click the .htaccess file and choose Edit.

Step 2: Add the Execution Time Directive

  1. Add the following line of code to the .htaccess file:
    php_value max_execution_time 300

    This sets the maximum execution time to 300 seconds (5 minutes).

  2. Save the changes and close the file editor.

Method 3: Edit the wp-config.php File

You can also try increasing the execution time by editing the wp-config.php file, which controls various WordPress settings.

Step 1: Access the wp-config.php File

  1. In your site’s root directory, locate the wp-config.php file.
  2. Right-click and choose Edit.

Step 2: Add the Execution Time Directive

  1. Add the following line of code near the top of the file, before the /* That’s all, stop editing! Happy publishing. */ comment:
    set_time_limit(300);

    This sets the execution time to 300 seconds (5 minutes).

  2. Save the file and exit the editor.

Method 4: Contact Your Hosting Provider

If you’re on shared hosting and cannot change the max_execution_time settings through the methods above, contact your hosting provider. They can adjust the settings for you, or they may offer an interface in your hosting control panel to change the max_execution_time.


Method 5: Use a WordPress Plugin

If you’re uncomfortable editing files manually, you can use a plugin to increase the max_execution_time.

  1. Log in to your WordPress dashboard.
  2. Navigate to Plugins > Add New.
  3. Search for WP Maximum Execution Time Exceeded or WP Server Info.
  4. Install and activate the plugin.
  5. Once installed, follow the plugin’s settings page instructions to increase the execution time.

How to Check if the Error is Fixed

  1. After applying one of the solutions above, go back to your WordPress dashboard and retry the action that caused the max_execution_time error.
  2. If the error persists, try increasing the time limit even more (e.g., 600 seconds or 10 minutes) or try one of the alternative methods.

Conclusion

The max_execution_time error in WordPress can be easily resolved by increasing the maximum execution time limit via php.ini, .htaccess, or wp-config.php, or by using a plugin. It’s essential to choose the method that best suits your technical comfort level and hosting environment. If none of these methods work, contacting your hosting provider is the best option for further assistance.

Test your skills on our all Hosting services and get 15% off!

Use code at checkout:

Skills