Fatal error: Maximum execution time of 300 seconds exceeded
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
Solution 1:
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:
Xampp Users
- Go to
xampp\phpMyAdmin\
- Open config.inc.php
- Search for
$cfg['ExecTimeLimit'] = 300;
- Set a larger value or change to 0 for unlimited
- If not found add
$cfg['ExecTimeLimit'] = 900;
(or 0 for unlimited) - Save the file and restart the server
Note that setting the execution time limit to unlimited is not recommended.
Solution 3:
At the beginning of your script you can add.
ini_set('MAX_EXECUTION_TIME', '-1');
Solution 4:
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:
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.