Fatal error: Maximum execution time of 300 seconds exceeded

PhpCommand Line-Interface

Php Problem Overview


I keep getting this PHP error:

> Fatal error: Maximum execution time of 300 seconds exceeded

I have tried setting my max_execution_time and my max_input_time settings in php.ini (both apache and cli) to 0, -1 and 4000 seconds each.

And i still get the error saying:

> Fatal error: Maximum execution time of 300 seconds exceeded

As well my script runs over 300 seconds before i get this message

I am running the script through command line.

I also checked my phpinfo() so see which php.ini I am using.

Even more interesting I have tried setting max_execution_time and max_input_time settings to 5 second and my script will run way beyond 5 seconds before I get the:

> Fatal error: Maximum execution time of 300 seconds exceeded

Php Solutions


Solution 1 - Php

If you are using WAMP Go to :

Increase the max_execution_time in php.ini then go to

C:\wamp\apps\phpmyadmin3.4.10.1\libraries (change path according to your installation)

open config.default.php and change value for $cfg['ExecTimeLimit'] to 0:

$cfg['ExecTimeLimit'] = 0;

This will resolve the issue for PhpMyAdmin imports.

Solution 2 - Php

Xampp Users

  1. Go to xampp\phpMyAdmin\
  2. Open config.inc.php
  3. Search for $cfg['ExecTimeLimit'] = 300;
  4. Set a larger value or change to 0 for unlimited
  5. If not found add $cfg['ExecTimeLimit'] = 900; (or 0 for unlimited)
  6. Save the file and restart the server

> Important: setting the execution time limit to unlimited is not recommended.

Solution 3 - Php

At the beginning of your script you can add.

ini_set('MAX_EXECUTION_TIME', '-1');

Solution 4 - Php

I encountered a similar situation, and it turns out that Codeigniter (the PHP framework I was using) actually sets its own time limit:

In system/core/Codeigniter.php, line 106 in version 2.1.3 the following appears:

if (function_exists("set_time_limit") == TRUE AND @ini_get("safe_mode") == 0)
{
	@set_time_limit(300);
}

As there was no other way to avoid changing the core file, I removed it so as to allow configuration through php.ini, as well as give the infinite maximum execution time for a CLI request.

I recommend recording this change somewhere in the case of future CI version upgrades however.

Solution 5 - Php

For Xampp Users

1. Go to C:\xampp\phpMyAdmin\libraries
2. Open config.default.php
3. Search for $cfg['ExecTimeLimit'] = 300;
4. Change to the Value 300 to 0 or set a larger value
5. Save the file and restart the server
6. OR Set the ini_set('MAX_EXECUTION_TIME', '-1'); at the beginning of your script you can add.

Solution 6 - Php

Try something like the following in your script:

set_time_limit(1200);

Solution 7 - Php

go to the xampp/phpmyadmin/libraries/config.default.php

and make the following changes

from  $cfg['ExecTimeLimit'] = ’300′;
to  $cfg['ExecTimeLimit'] = ’0′;

Solution 8 - Php

This is the the right answer:

go to

c:\wamp\apps\phpmyadmin3.4.10.1\libraries\config.default.php

find and set

$cfg['ExecTimeLimit'] = 0;

restart all services and done.

Solution 9 - Php

For Local AppServ

Go to C:\AppServ\www\phpMyAdmin\libraries\config.default.php

Find $cfg['ExecTimeLimit'] and set value to 0.

So it'll look like

$cfg['ExecTimeLimit'] = 0;

Solution 10 - Php

If xampp in localserver Goto C:\xampp\phpMyAdmin\libraries\config.default.php

//find $cfg['ExecTimeLimit']= 300;
//increase this value 
$cfg['ExecTimeLimit'] = 3000;

Solution 11 - Php

PHP's CLI's default execution time is infinite.

> This sets the maximum time in seconds a script is allowed to run > before it is terminated by the parser. This helps prevent poorly > written scripts from tying up the server. The default setting is 30. > When running PHP from the command line the default setting is 0.

http://gr.php.net/manual/en/info.configuration.php#ini.max-execution-time

Check if you're running PHP in safe mode, because it ignores all time exec settings when on that.

Solution 12 - Php

MAMP USERS editing php.ini solves this - there is a line:

max_execution_time = 30 ; Maximum execution time of each script, in seconds

setting this to a higher value worked.

the file is in php/php5.6.25/conf/php.ini (obviousl you need to wet the file for the php version you are using - you can find this out from the MAMP preferences.

Solution 13 - Php

If you are on xampp and using phpMyadmin to import large sql files and you have increased max_execution time, max file upload limit and everything needed And If none of the above answers work for you come here

Go to your xampp folder, in my case here is the relative path to the file that I need to modify: C:\xampp\phpMyAdmin\libraries\config.default.php

`/**

  • maximum execution time in seconds (0 for no limit)
  • @global integer $cfg['ExecTimeLimit']
  • by defautlt 300 is the value
  • change it to 0 for unlimited
  • time is seconds
  • Line 709 for me */ $cfg['ExecTimeLimit'] = 0;`

Solution 14 - Php

WAMP USERS:

  1. Go to C:\wamp\apps\phpmyadmin

  2. Open config.inc

  3. Add $cfg['ExecTimeLimit'] = ’3600′; to the file.

  4. Save the file and restart the server.

This file overwrites the php.ini and will work for you!

Solution 15 - Php

In my case, when I faced that error in Phpmyadmin, I tried MySQL-Front and import my DB successfully.

Note: You can still use the provided solutions under this question to solve your problem in Phpmyadmin.

Solution 16 - Php

If above answers will not work, try to check your code,,In my experience,having an infinite loop will also cause that problem.Check your else if statement.

Solution 17 - Php

In Codeignitor version 3.0.x the system/core/Codeigniter.php do not contain the time constraint as well as inserting

ini_set('MAX_EXECUTION_TIME', -1);  

will not work since codeignitor will override that with its own function set_time_limit() . So either you have to delete that function from codeignitor or simply you can insert

set_time_limit('1000');

in the beginning of the php file if you wanna change that to 1000 seconds. Set the time to 0 (zero) if you want to run it as long as it want.

Solution 18 - Php

On Xampp, in php.ini you must check mysql.connect_timeout either. So, for example, change it to:

mysql.connect_timeout = 3600

That time will be always counted in seconds (so 1 hour in my example)

Solution 19 - Php

On wamp in my configuration where I have multiple phpmyadmins, the values in config files were overwritten in wamp/alias/phpmyadmin.conf. I set up two lines there:

1. php_admin_value max_execution_time 3600

2. php_admin_value max_input_time 3600

... it finally worked!

Solution 20 - Php

For OpenServer

modules\system\html\openserver\phpmyadmin\libraries\config.default.php

change

$cfg[‘ExecTimeLimit’] = 600

Solution 21 - Php

You can set time limit:

ini_set('max_execution_time', 1000000000000000);

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiondezView Question on Stackoverflow
Solution 1 - PhpVipin DubeyView Answer on Stackoverflow
Solution 2 - PhpTechnotronicView Answer on Stackoverflow
Solution 3 - PhpTulesView Answer on Stackoverflow
Solution 4 - PhpxiankaiView Answer on Stackoverflow
Solution 5 - PhpRafiqul IslamView Answer on Stackoverflow
Solution 6 - PhpDarth EgregiousView Answer on Stackoverflow
Solution 7 - PhpGaurav AroraView Answer on Stackoverflow
Solution 8 - PhpllioorView Answer on Stackoverflow
Solution 9 - PhpZunnie KanittikaView Answer on Stackoverflow
Solution 10 - PhpMOAZZAM RASOOLView Answer on Stackoverflow
Solution 11 - PhpMobView Answer on Stackoverflow
Solution 12 - PhpJeremy YoungView Answer on Stackoverflow
Solution 13 - PhpNoor AhmedView Answer on Stackoverflow
Solution 14 - PhpAsiView Answer on Stackoverflow
Solution 15 - PhpJamshid HashimiView Answer on Stackoverflow
Solution 16 - Phpuser2338925View Answer on Stackoverflow
Solution 17 - PhpWenukaView Answer on Stackoverflow
Solution 18 - PhpandymncView Answer on Stackoverflow
Solution 19 - Phpferdinand64View Answer on Stackoverflow
Solution 20 - PhpYurgenTMView Answer on Stackoverflow
Solution 21 - Phpbinhhoang18View Answer on Stackoverflow