Once ticket is created, we offer assistance within 24 hours. We appreciate for your understanding.

Okay
  Print

How to Increase Max Execution Time (300s) for Your Website

The Max Execution Time setting in PHP determines the maximum time a script is allowed to run before being terminated. If your website handles long-running tasks, such as large file uploads, data imports, or plugin/theme updates, you might encounter errors like "Maximum execution time exceeded." Increasing the Max Execution Time can resolve these issues.

What Is Max Execution Time?

The max_execution_time directive in PHP defines the time limit (in seconds) for script execution. By default, this is set to 30 seconds, but many hosting environments set it to 300 seconds. If a script runs longer than this time, it will terminate to prevent server overload.

Step 1: Check the Current Max Execution Time

Before making changes, determine the current max_execution_time value:

A) Using PHP Info

  1. Create a file named phpinfo.php with the following code:
    <?php
    phpinfo();
    ?>
    
  2. Upload the file to your website's root directory.
  3. Open the file in your browser (e.g., http://yourwebsite.com/phpinfo.php).
  4. Look for max_execution_time in the output.

B) Using Your Website Admin Panel

  1. Log in to your website's admin panel.
  2. Navigate to System Info or Server Settings.
  3. Look for the max_execution_time value.

Step 2: Increase Max Execution Time

Here are several methods to increase the max_execution_time value, depending on your hosting environment:

A) Edit php.ini

  1. Access your server via FTP or your hosting control panel.
  2. Locate the php.ini file (commonly in the root directory or /etc/).
  3. Open the file and add or update the following line:
    max_execution_time = 300
    
    Replace 300 with the desired value, such as 600 for 10 minutes.
  4. Save the file and restart your server.

B) Modify .htaccess (For Apache Servers)

  1. Open the .htaccess file located in your website’s root directory.
  2. Add the following line:
    php_value max_execution_time 300
    
    Replace 300 with your desired value.
  3. Save the file. The changes will take effect immediately.

C) Update Using cPanel or Hosting Dashboard

  1. Log in to your hosting provider’s control panel.
  2. Navigate to PHP Settings or MultiPHP INI Editor.
  3. Find the max_execution_time option.
  4. Increase the value to 300 or higher (e.g., 600).
  5. Save the changes.

D) Use a .user.ini File (For Shared Hosting)

  1. If you’re on shared hosting, create or edit a .user.ini file in your website’s root directory.
  2. Add the following line:
    max_execution_time = 300
    
  3. Save the file. Changes may take a few minutes to apply.

E) Set Using WordPress wp-config.php (Temporary Solution)

  1. Open the wp-config.php file in your WordPress installation directory.
  2. Add the following line before /* That's all, stop editing! Happy publishing. */:
    @ini_set('max_execution_time', 300);
    
    This method overrides the server setting but is temporary and may not work on some hosts.

F) Contact Your Hosting Provider

If you’re unable to modify the settings yourself, contact your hosting provider and request an increase in max_execution_time.

Step 3: Verify the New Max Execution Time

  1. Refresh your website or clear the server cache.
  2. Revisit the phpinfo.php file or your admin panel to confirm the updated value.
  3. Test the functionality that was previously timing out.

Troubleshooting Common Issues

  • Changes Not Applied: Ensure you edited the correct configuration file and restarted the server if required.
  • Shared Hosting Restrictions: Some hosting providers enforce strict limits. Contact them for assistance.
  • Syntax Errors: Ensure there are no typos in the .htaccess or php.ini files.

Best Practices

  • Avoid setting excessively high values to prevent server strain.
  • Monitor your server performance and logs to ensure stability after increasing the limit.
  • Use optimized scripts and processes to reduce execution time wherever possible.

Conclusion

Increasing the Max Execution Time is essential for handling long-running scripts on your website. By following the steps outlined above, you can prevent timeout errors and ensure smooth operations. If you encounter difficulties, your hosting provider can assist in adjusting the settings for you.