I have the following set up:
PHP Fatal error: Maximum execution time of 30 seconds exceeded in. PDO.php on line 478 #978 c0d3z3r0 opened this issue Jun 29, 2017 9 comments. You may receive a message such as “Maximum execution time of 30 seconds exceeded” or “Maximum execution time of 60 seconds exceeded”. This means that it is taking to longer for a process to complete and it is timing out.
In routes I have:
Route::get('articles', 'ArticlesController@index');
The index method in the controller is simply:
and in the view:
I attempted to replace the:
with
such that I can actually show the articles latest first.I got the error:
and the call stack is:
... etc
I have restored the controller method to what it was, but the error persists.
Can you please tell me how I can solve this problem?
Geordie GadgieGeordie Gadgie
9 Answers
The Maximum execution time of 30 seconds exceeded error is not related to Laravel but rather your PHP configuration.
Here is how you can fix it. The setting you will need to change is
max_execution_time
. You can change the
max_execution_time
to 300
seconds like max_execution_time = 300
You can find the path of your PHP configuration file in the output of the
phpinfo
function in the Loaded Configuration File
section.Noman Ur RehmanNoman Ur Rehman
it's a pure PHP setting.The alternative is to increase the execution time limit only for specific php scripts, by inserting on top of that php file, the following:
Grigoreas P.Grigoreas P.
In Laravel:
Add set_time_limit(0) line on top of query.
It helps you in different large queries but you should need to improve query optimise.
Umar TariqUmar Tariq
Sometimes you just need to optimize your code or query, Setting more max_execution_time is not a solution.
A code should not be run more than 30s.
Alireza AboutalebiAlireza Aboutalebi
If using PHP7, I would suggest you changing the default value in the public/.htaccess
Kwaye KantKwaye Kant
try
where
$time
is in seconds, set it to 0 for no time. make sure to make it 60 back after your function finishkarrar kazuyakarrar kazuya
set time limit in __construct method or you can set in your index controller also where you want to have large time limit.
Mahendra PratapMahendra Pratap
Carlos RamírezCarlos Ramírez
You need to just press CTRL + F5. It will work after that.
Bhargav Rao♦
Sandro CagaraSandro Cagara
Not the answer you're looking for? Browse other questions tagged phplaravel or ask your own question.
Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.
Sign upHave a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
commented Oct 13, 2016 • edited by Synchro
edited by Synchro
I am getting error as below. My Code is as below... Same code runs successfully and Email is sent to user on my laptop. But in Office PC I am getting this error. |
commented Oct 13, 2016
30 seconds is nowhere near long enough for reliable SMTP, you definitely need to increase the max execution time in your php.ini. That said, it probably won't help in this case. You probably have some kind of network issue on your office PC which you can test for by reading the troubleshooting guide in the wiki. I can also see that you have based your code on an obsolete example, and you're probably using an old version of PHPMailer. |
commented Nov 5, 2016
I am getting email of users from database with while loop and sending email through PhpMailer, but its give an error of Maximum execution time 30 second . How can i fix it ? |
commented Nov 5, 2016
Increase you max execution time in your php.ini, or hand it off to an async process. |
commented Nov 5, 2016
where is php.ini file can you please proper guide to me ? |
commented Nov 5, 2016
i changed the max_execution_time to 300sec in php.ini file but its still giving an error! Fatal error: Maximum execution time of 30 seconds exceeded in C:xampphtdocsbims2016PHPMailerclass.smtp.php on line 276 |
commented Nov 5, 2016 • edited
edited
Restart your web server for it to pick the changes in your php.ini. |
commented Nov 6, 2016
Thank you so much its working :) |
commented Apr 18, 2017
Dear frnds my code bt im fnd the error Message could not be sent.Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting SMTPDebug = 3; // Enable verbose debug output$mail->isSMTP(); // Set mailer to use SMTP$mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers$mail->SMTPAuth = true; // Enable SMTP authentication$mail->Username = '[email protected]'; // SMTP username$mail->Password = '; // SMTP password$mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted$mail->Port =587; // TCP port to connect to$mail->setFrom('[email protected]', 'SUMEET BHARDWAJ');$mail->addAddress($email); // Add a recipient$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name$mail->isHTML(true); // Set email format to HTML$mail->Subject = 'Confirmation Code';$mail->Body = 'Thank You! For Joining Your Confirmation code is:'.$ver_code;$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';if(!$mail->send()) { echo 'Message could not be sent.'; echo 'Mailer Error: ' . $mail->ErrorInfo;} else { echo 'Message has been sent';}} |
commented Apr 18, 2017
Please read the thread before posting. The SMTP specification allows servers to take up to 10 minutes to respond to commands, so you need to increase max_execution_time in your php.ini file to allow your scripts to take that long. |
commented Apr 18, 2017
hello Sir, how to increase time plz tell me. plz sir |
commented Apr 18, 2017
Read the docs like everyone else does. |
commented Jan 15, 2018
I'm trying to send mail to localhost at many times but. I have to reach different error at different times.can you help me to remove this error . Fatal error: Maximum execution time of 30 seconds exceeded in C:xampphtdocsmailPHPMailer-masterclass.smtp.php on line 1227 |
commented Jan 15, 2018
You could try reading this thread, since it tells you exactly what to do. |
commented Mar 21, 2018
Aqui deu tudo certo, muito obrigado! |
locked as resolved and limited conversation to collaborators Mar 21, 2018
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.