Internet Related, Tutorials

How to fix maximum execution time exceeded error

maximum execution time in wordpress
maximum execution time

If you are maintaining or hosting a website which is using php scripts like Drupal or WordPress CMS or any custom build website, then you will surely face “Fatal error: Maximum execution time of 30 seconds exceeded error; if you have not faced yet. This error is very common in opensource CMS like WordPress, Drupal etc where lots of queries need to run to show the contents of some pages.

By default, hosting providers set 30 seconds execution time to any of your php scripts in their php configuration file i.e. ‘php.ini’. Usually you can’t this value as you will not have access to php.ini. Otherwise it’s just matter of one line change in php.ini.

Majority of servers have 30 seconds as maximum execution time. This image from shows the stats of the servers vs maximum execution time.

php_max_execution_time servers stats

Method 1

php.ini-max_execution_time settingsIn case, you have access to php.ini file (if you are running website in localhost or VPS etc.)   Find php.ini (will be inside Apache) and find max_execution_time keyword. Sometime, they allow you to create your own php.ini and it will override server’s php.ini value (If you are lucky).

Change the value from 30 to 300 (it’s in seconds)

max_execution_time = 300

Method 2

Other way is to update max_execution_time value using .htaccess. Add below line in your .htaccess file in your root folder

php_value max_execution_time 300

Method 3 (For Drupal)

Add below line in sites/default/settings.php

ini_set('max_execution_time', 0);

Note: You may face memory issue along with maximum execution time. In that case just add maximum memory limit in

  • .htaccess as php_value memory_limit 256M
  • ini as memory_limit = 256M ;
  • In Drupal at sites/default/settings.php as ini_set(‘memory_limit’, ‘256M’);
error maximum execution time in wordpress
error maximum execution time in WordPress

Share your comment