I have a Laravel app that I'm serving in Digital Ocean through Laravel Forge, I am using the email server from my old shared server from HostGator, my configuration is as follows:
MAIL_DRIVER=smtp
MAIL_HOST=cloud232.hostgator.com
MAIL_FROM_ADDRESS=noreply#*********
MAIL_FROM_NAME=noreply
MAIL_USERNAME=noreply#************
MAIL_PASSWORD=********************
MAIL_ENCRYPTION=tls
MAIL_PORT=587
THIS WORKS CORRECTLY, I AM ABLE TO SEND EMAILS.
And I have a method that filters the database with one passed argument and then sends the emails to the filtered customers.
I call this method from a URL using cron jobs on forge (not the Laravel scheduler but an entry in the cron jobs tables).
As I've been using this for the past few months, now I have added another method that calls the same function but filters the DB in different way (and the collection returns correctly), but the new method could not send any email because I get a connection refused error like this one:
Connection could not be established with host cloud232.hostgator.com [Connection refused #111]
And this is the stack trace:
#0 /home/forge/prestamos.ikiwi.net.ar/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php(58): Swift_Transport_StreamBuffer->establishSocketConnection()
#1 /home/forge/prestamos.ikiwi.net.ar/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(143): Swift_Transport_StreamBuffer->initialize(Array)
#2 /home/forge/prestamos.ikiwi.net.ar/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mailer.php(65): Swift_Transport_AbstractSmtpTransport->start()
#3 /home/forge/prestamos.ikiwi.net.ar/vendor/laravel/framework/src/Illuminate/Mail/Mailer.php(484): Swift_Mailer->send(Object(Swift_Message), Array)
#4 /home/forge/prestamos.ikiwi.net.ar/vendor/laravel/framework/src/Illuminate/Mail/Mailer.php(259): Illuminate\Mail\Mailer->sendSwiftMessage(Object(Swift_Message))
#5 /home/forge/prestamos.ikiwi.net.ar/vendor/laravel/framework/src/Illuminate/Mail/Mailable.php(159): Illuminate\Mail\Mailer->send(Object(Illuminate\Support\HtmlString), Array, Object(Closure))
#6 /home/forge/prestamos.ikiwi.net.ar/vendor/laravel/framework/src/Illuminate/Support/Traits/Localizable.php(19): Illuminate\Mail\Mailable->Illuminate\Mail\{closure}()
#7 /home/forge/prestamos.ikiwi.net.ar/vendor/laravel/framework/src/Illuminate/Mail/Mailable.php(160): Illuminate\Mail\Mailable->withLocale(NULL, Object(Closure))
#8 /home/forge/prestamos.ikiwi.net.ar/vendor/laravel/framework/src/Illuminate/Mail/Mailer.php(275): Illuminate\Mail\Mailable->send(Object(Illuminate\Mail\Mailer))
#9 /home/forge/prestamos.ikiwi.net.ar/vendor/laravel/framework/src/Illuminate/Mail/Mailer.php(229): Illuminate\Mail\Mailer->sendMailable(Object(App\Mail\CompleteRegistration))
#10 /home/forge/prestamos.ikiwi.net.ar/vendor/laravel/framework/src/Illuminate/Mail/PendingMail.php(127): Illuminate\Mail\Mailer->send(Object(App\Mail\CompleteRegistration))
#11 /home/forge/prestamos.ikiwi.net.ar/app/Http/Controllers/CustomerController.php(100): Illuminate\Mail\PendingMail->send(Object(App\Mail\CompleteRegistration))
#12 /home/forge/prestamos.ikiwi.net.ar/app/Http/Controllers/CustomerController.php(90): App\Http\Controllers\CustomerController::sendMail(2, 3, Object(Illuminate\Database\Eloquent\Collection))
#13 /home/forge/prestamos.ikiwi.net.ar/app/Http/Controllers/CustomerController.php(26): App\Http\Controllers\CustomerController::sendReminder(3, 599)
#14 [internal function]: App\Http\Controllers\CustomerController::thirdReminder()
#15 /home/forge/prestamos.ikiwi.net.ar/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): call_user_func_array(Array, Array)
#16 /home/forge/prestamos.ikiwi.net.ar/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\Routing\Controller->callAction('thirdReminder', Array)
#17 /home/forge/prestamos.ikiwi.net.ar/vendor/laravel/framework/src/Illuminate/Routing/Route.php(219): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(App\Http\Controllers\CustomerController), 'thirdReminder')
#18 /home/forge/prestamos.ikiwi.net.ar/vendor/laravel/framework/src/Illuminate/Routing/Route.php(176): Illuminate\Routing\Route->runController()
#19 /home/forge/prestamos.ikiwi.net.ar/vendor/laravel/framework/src/Illuminate/Routing/Router.php(680): Illuminate\Routing\Route->run()
#20 /home/forge/prestamos.ikiwi.net.ar/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\Routing\Router->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#21 /home/forge/prestamos.ikiwi.net.ar/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(41): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#22 /home/forge/prestamos.ikiwi.net.ar/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Routing\Middleware\SubstituteBindings->handle(Object(Illuminate\Http\Request), Object(Closure))
#23 /home/forge/prestamos.ikiwi.net.ar/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#24 /home/forge/prestamos.ikiwi.net.ar/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php(58): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#25 /home/forge/prestamos.ikiwi.net.ar/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Routing\Middleware\ThrottleRequests->handle(Object(Illuminate\Http\Request), Object(Closure), 60, '1')
#26 /home/forge/prestamos.ikiwi.net.ar/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#27 /home/forge/prestamos.ikiwi.net.ar/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#28 /home/forge/prestamos.ikiwi.net.ar/vendor/laravel/framework/src/Illuminate/Routing/Router.php(682): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#29 /home/forge/prestamos.ikiwi.net.ar/vendor/laravel/framework/src/Illuminate/Routing/Router.php(657): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#30 /home/forge/prestamos.ikiwi.net.ar/vendor/laravel/framework/src/Illuminate/Routing/Router.php(623): Illuminate\Routing\Router->runRoute(Object(Illuminate\Http\Request), Object(Illuminate\Routing\Route))
#31 /home/forge/prestamos.ikiwi.net.ar/vendor/laravel/framework/src/Illuminate/Routing/Router.php(612): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#32 /home/forge/prestamos.ikiwi.net.ar/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#33 /home/forge/prestamos.ikiwi.net.ar/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))
#34 /home/forge/prestamos.ikiwi.net.ar/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#35 /home/forge/prestamos.ikiwi.net.ar/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Fideloper\Proxy\TrustProxies->handle(Object(Illuminate\Http\Request), Object(Closure))
#36 /home/forge/prestamos.ikiwi.net.ar/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#37 /home/forge/prestamos.ikiwi.net.ar/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#38 /home/forge/prestamos.ikiwi.net.ar/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#39 /home/forge/prestamos.ikiwi.net.ar/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#40 /home/forge/prestamos.ikiwi.net.ar/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#41 /home/forge/prestamos.ikiwi.net.ar/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#42 /home/forge/prestamos.ikiwi.net.ar/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#43 /home/forge/prestamos.ikiwi.net.ar/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#44 /home/forge/prestamos.ikiwi.net.ar/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle(Object(Illuminate\Http\Request), Object(Closure))
#45 /home/forge/prestamos.ikiwi.net.ar/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#46 /home/forge/prestamos.ikiwi.net.ar/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(62): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#47 /home/forge/prestamos.ikiwi.net.ar/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))
#48 /home/forge/prestamos.ikiwi.net.ar/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#49 /home/forge/prestamos.ikiwi.net.ar/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#50 /home/forge/prestamos.ikiwi.net.ar/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(151): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#51 /home/forge/prestamos.ikiwi.net.ar/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#52 /home/forge/prestamos.ikiwi.net.ar/public/index.php(55): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#53 {main}
How can this happen if it is exactly the same code??
foreach ($customers as $customer) {
try {
Mail::to($customer->email)->send(new CompleteRegistration($step, $reminderCount, $customer));
} catch (\Exception $e) {
\Log::error($e->getMessage());
}
}
Thanks in advance.
Run php artisan config:cache after making changes in .env
I think this may help you.
According to HostGator documentation:
Any time you're sending a message no matter how large your e-mail list is you must throttle it. We recommend you throttle it to at the very least sending 1 email every 8 seconds. (Sending 1 every 8 seconds would send 450 emails within 1 hour, keeping you below the 500 outgoing email limit.) If the mailing list software you're using does not allow you to throttle you must switch to an application or script that will. We recommend PHPList, which can be found in your CPanel, under Quickinstall.
IMPORTANT: If you do not throttle and you try sending 500 emails, the server will try sending all 500 in 1 second which is not possible on our shared servers. This will cause a very high load on the server and the entire server will be sluggish, potentially affecting your sites and service, until this sending process is completed. It is our job to keep the server up and running without being sluggish or experiencing issues. Anyone who causes the server's load to go high will be suspended and the process will be terminated. If you choose not to throttle, you will most likely be suspended for crashing the server.
I began to try with smaller mailing lists, and it turns out that I'm able to send no more than 7 emails per process, so the way to solve this is to throttling the send process.
The reason why it didn't happen with the other old processes that I have is that I run them with very short time between them, so the list is never big enough, for this thread that I opened, I run the new method once a day, so the list gets bigger and bigger.
As I am working with Laravel I will think a solution combining cron jobs, jobs and queues, thank you very much for you effort and answers, hope this thread will help other people.
Related
Recently I've upgraded Laravel from 5.8 to 6.0 and made some adjusts to make it running smoothly.
In my local environment, it works fine. But when I publish in my server, when I try to send some notifications (mail and broadcast) I receive the following error:
ErrorException: Undefined property: Illuminate\Notifications\ChannelManager::$container in /var/www/vialoc_api/vendor/laravel/framework/src/Illuminate/Notifications/ChannelManager.php:53
Stack trace:
#0 /var/www/vialoc_api/vendor/laravel/framework/src/Illuminate/Notifications/ChannelManager.php(53): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(8, 'Undefined prope...', '/var/www/vialoc...', 53, Array)
#1 /var/www/vialoc_api/vendor/laravel/framework/src/Illuminate/Notifications/SendQueuedNotifications.php(73): Illuminate\Notifications\ChannelManager->sendNow(Object(App\Models\User), Object(App\Notifications\UserConfirmationNotification), Array)
#2 [internal function]: Illuminate\Notifications\SendQueuedNotifications->handle(Object(Illuminate\Notifications\ChannelManager))
#3 /var/www/vialoc_api/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(32): call_user_func_array(Array, Array)
#4 /var/www/vialoc_api/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(90): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#5 /var/www/vialoc_api/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(34): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#6 /var/www/vialoc_api/vendor/laravel/framework/src/Illuminate/Container/Container.php(580): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#7 /var/www/vialoc_api/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(94): Illuminate\Container\Container->call(Array)
#8 /var/www/vialoc_api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(130): Illuminate\Bus\Dispatcher->Illuminate\Bus\{closure}(Object(Illuminate\Notifications\SendQueuedNotifications))
#9 /var/www/vialoc_api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(105): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Notifications\SendQueuedNotifications))
#10 /var/www/vialoc_api/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(98): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#11 /var/www/vialoc_api/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(83): Illuminate\Bus\Dispatcher->dispatchNow(Object(Illuminate\Notifications\SendQueuedNotifications), false)
#12 /var/www/vialoc_api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(130): Illuminate\Queue\CallQueuedHandler->Illuminate\Queue\{closure}(Object(Illuminate\Notifications\SendQueuedNotifications))
#13 /var/www/vialoc_api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(105): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Notifications\SendQueuedNotifications))
#14 /var/www/vialoc_api/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(85): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#15 /var/www/vialoc_api/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(59): Illuminate\Queue\CallQueuedHandler->dispatchThroughMiddleware(Object(Illuminate\Queue\Jobs\RedisJob), Object(Illuminate\Notifications\SendQueuedNotifications))
#16 /var/www/vialoc_api/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(88): Illuminate\Queue\CallQueuedHandler->call(Object(Illuminate\Queue\Jobs\RedisJob), Array)
#17 /var/www/vialoc_api/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(327): Illuminate\Queue\Jobs\Job->fire()
#18 /var/www/vialoc_api/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(277): Illuminate\Queue\Worker->process('redis', Object(Illuminate\Queue\Jobs\RedisJob), Object(Illuminate\Queue\WorkerOptions))
#19 /var/www/vialoc_api/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(118): Illuminate\Queue\Worker->runJob(Object(Illuminate\Queue\Jobs\RedisJob), 'redis', Object(Illuminate\Queue\WorkerOptions))
#20 /var/www/vialoc_api/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(102): Illuminate\Queue\Worker->daemon('redis', 'vialoc-api,defa...', Object(Illuminate\Queue\WorkerOptions))
#21 /var/www/vialoc_api/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(86): Illuminate\Queue\Console\WorkCommand->runWorker('redis', 'vialoc-api,defa...')
#22 [internal function]: Illuminate\Queue\Console\WorkCommand->handle()
#23 /var/www/vialoc_api/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(32): call_user_func_array(Array, Array)
#24 /var/www/vialoc_api/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(90): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#25 /var/www/vialoc_api/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(34): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#26 /var/www/vialoc_api/vendor/laravel/framework/src/Illuminate/Container/Container.php(580): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#27 /var/www/vialoc_api/vendor/laravel/framework/src/Illuminate/Console/Command.php(183): Illuminate\Container\Container->call(Array)
#28 /var/www/vialoc_api/vendor/symfony/console/Command/Command.php(255): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#29 /var/www/vialoc_api/vendor/laravel/framework/src/Illuminate/Console/Command.php(170): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#30 /var/www/vialoc_api/vendor/symfony/console/Application.php(908): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#31 /var/www/vialoc_api/vendor/symfony/console/Application.php(269): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Queue\Console\WorkCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#32 /var/www/vialoc_api/vendor/symfony/console/Application.php(145): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#33 /var/www/vialoc_api/vendor/laravel/framework/src/Illuminate/Console/Application.php(90): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#34 /var/www/vialoc_api/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(122): Illuminate\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#35 /var/www/vialoc_api/artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#36 {main}
And one note: To upgrade to Laravel 6 on my server, I needed to upgrade to PHP 7.2. I've done this and I think there is some PHP module missing. But I'm stuck to resolve this issue.
To notifications, I'm using Redis for Queue. And I've tried to sent the emails through mailtrap and mailgun, but the response is the same.
Please someone can help me? Tks a lot in advance.
I've discovered the problem.
My queue was being managed by a supervisor process. And with the upgrade and the code change, the process didn't update the code being processed.
When I ran the following command:
sudo supervisorctl restart all
Everything starts working again.
Running composer install on your server should list any missing modules.
(Newbie here, with what I hope is a simple problem!)
After running WP for years, I decided to try something a bit more 'involved' and switched to OctoberCMS and poked around on W3Schools PHP.
But after a recent RainLab Blog update, my site only reroutes to an Exception Error. This is what I get for playing webmaster.
The error message is as follows:
The component 'RainLab\Blog\Components\Post' does not contain a method 'getRouter'
catch (BadMethodCallException $ex) {}
if (method_exists($this->controller, $method)) {
return call_user_func_array([$this->controller, $method], $parameters);
}
throw new BadMethodCallException(Lang::get('cms::lang.component.method_not_found', [
'name' => get_class($this),
'method' => $method
]));
}
/**
I can access the file in question (having downloaded it for analysis) but cannot figure out how to fix the error, or even what getRouter is!
Google has failed me, and I just need a little bit of direction!
I have looked at the documentation on GitHub, and at similar error messages elsewhere, but I do not at this time understand enough to extrapolate my solution from any others.
The installation is all default, aside from some CSS changes and stylesheets I modified. AFAIK, CSS should not be interfering with the PHP backend however.
As far as solutions: If there is a way to prevent this handling; any method that allows the site to display as normal (rather than throwing this stupid error message)!
EDIT: Here is a backend log (sorry for the length--I am unsure what exactly is important.
EDIT 2: As far as I know, nothing is "custom" beyond having a few different plugins installed--Blog, Comments, Embed, and a couple others.
(I thought a minimal installation would help avoid this! But I am enjoying learning overall, despite the frustrations.)
Dashboard CMS Media Pages Blog Comments Users Settings
Misc
Comments Manage Settings.
CMS
Front-end theme Manage the front-end theme and customization options.
Maintenance mode Configure the maintenance mode page and toggle the setting.
System
Updates & Plugins Update the system, manage and install plugins and themes.
Administrators Manage back-end administrator users, groups and permissions.
Editor settings Customize the global editor preferences, such as font size and color scheme.
Customize back-end Customize the administration area such as name, colors and logo.
Users
User settings Manage user based settings.
Blog
Blog Manage blog settings
Mail
Logs
Event log View system log messages with their recorded time and details.
Theme log View changes made to the active theme.
Request log View bad or redirected requests, such as Page not found (404).
Access log View a list of successful back-end user sign ins.
Log settings Specify which areas should use logging.
Event log Event
Event ID
#2899
Level
Error
Date & Time
Sun, Jun 16, 2019 7:40 PM
Formatted
Raw
BadMethodCallException: The component 'RainLab\Blog\Components\Post' does not contain a method 'getRouter'. in /home/andmorew/public_html/modules/cms/classes/ComponentBase.php:315
Stack trace:
#0 /home/andmorew/public_html/plugins/vdomah/blogviews/Plugin.php(63): Cms\Classes\ComponentBase->__call('getRouter', Array)
#1 [internal function]: Vdomah\BlogViews\Plugin->Vdomah\BlogViews\{closure}(Object(RainLab\Blog\Components\Post))
#2 /home/andmorew/public_html/vendor/october/rain/src/Extension/ExtendableTrait.php(60): call_user_func(Object(Closure), Object(RainLab\Blog\Components\Post))
#3 /home/andmorew/public_html/vendor/october/rain/src/Extension/Extendable.php(31): October\Rain\Extension\Extendable->extendableConstruct()
#4 /home/andmorew/public_html/modules/cms/classes/ComponentBase.php(98): October\Rain\Extension\Extendable->__construct()
#5 [internal function]: Cms\Classes\ComponentBase->__construct(NULL, Array)
#6 /home/andmorew/public_html/vendor/october/rain/src/Foundation/Maker.php(85): ReflectionClass->newInstanceArgs(Array)
#7 /home/andmorew/public_html/vendor/october/rain/src/Foundation/Maker.php(42): October\Rain\Foundation\Maker->build('\\RainLab\\Blog\\C...', Array)
#8 /home/andmorew/public_html/vendor/october/rain/src/Foundation/Application.php(155): October\Rain\Foundation\Maker->make('\\RainLab\\Blog\\C...', Array)
#9 /home/andmorew/public_html/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(221): October\Rain\Foundation\Application->make('\\RainLab\\Blog\\C...', Array)
#10 /home/andmorew/public_html/modules/cms/classes/ComponentManager.php(213): Illuminate\Support\Facades\Facade::__callStatic('make', Array)
#11 /home/andmorew/public_html/modules/cms/classes/CmsCompoundObject.php(225): Cms\Classes\ComponentManager->makeComponent('blogPost', NULL, Array)
#12 /home/andmorew/public_html/plugins/rainlab/blog/classes/ComponentAbstract.php(35): Cms\Classes\CmsCompoundObject->getComponent('blogPost')
#13 /home/andmorew/public_html/plugins/rainlab/blog/components/Posts.php(222): RainLab\Blog\Classes\ComponentAbstract->getComponent('blogPost', Object(Cms\Classes\Page))
#14 /home/andmorew/public_html/plugins/rainlab/blog/components/Posts.php(169): RainLab\Blog\Components\Posts->listPosts()
#15 /home/andmorew/public_html/modules/cms/classes/CmsCompoundObject.php(172): RainLab\Blog\Components\Posts->onRun()
#16 /home/andmorew/public_html/modules/cms/classes/Controller.php(500): Cms\Classes\CmsCompoundObject->runComponents()
#17 /home/andmorew/public_html/modules/cms/classes/Controller.php(393): Cms\Classes\Controller->execPageCycle()
#18 /home/andmorew/public_html/modules/cms/classes/Controller.php(224): Cms\Classes\Controller->runPage(Object(Cms\Classes\Page))
#19 /home/andmorew/public_html/modules/cms/classes/CmsController.php(50): Cms\Classes\Controller->run('/')
#20 [internal function]: Cms\Classes\CmsController->run('/')
#21 /home/andmorew/public_html/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): call_user_func_array(Array, Array)
#22 /home/andmorew/public_html/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\Routing\Controller->callAction('run', Array)
#23 /home/andmorew/public_html/vendor/laravel/framework/src/Illuminate/Routing/Route.php(212): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(Cms\Classes\CmsController), 'run')
#24 /home/andmorew/public_html/vendor/laravel/framework/src/Illuminate/Routing/Route.php(169): Illuminate\Routing\Route->runController()
#25 /home/andmorew/public_html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(658): Illuminate\Routing\Route->run()
#26 /home/andmorew/public_html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\Routing\Router->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#27 /home/andmorew/public_html/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(41): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#28 /home/andmorew/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\Routing\Middleware\SubstituteBindings->handle(Object(Illuminate\Http\Request), Object(Closure))
#29 /home/andmorew/public_html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#30 /home/andmorew/public_html/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#31 /home/andmorew/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#32 /home/andmorew/public_html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#33 /home/andmorew/public_html/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(63): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#34 /home/andmorew/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#35 /home/andmorew/public_html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#36 /home/andmorew/public_html/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#37 /home/andmorew/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(Illuminate\Http\Request), Object(Closure))
#38 /home/andmorew/public_html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#39 /home/andmorew/public_html/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(66): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#40 /home/andmorew/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure))
#41 /home/andmorew/public_html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#42 /home/andmorew/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#43 /home/andmorew/public_html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(660): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#44 /home/andmorew/public_html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(635): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#45 /home/andmorew/public_html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(601): Illuminate\Routing\Router->runRoute(Object(Illuminate\Http\Request), Object(Illuminate\Routing\Route))
#46 /home/andmorew/public_html/vendor/october/rain/src/Router/CoreRouter.php(20): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#47 /home/andmorew/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): October\Rain\Router\CoreRouter->dispatch(Object(Illuminate\Http\Request))
#48 /home/andmorew/public_html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))
#49 /home/andmorew/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(46): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#50 /home/andmorew/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))
#51 /home/andmorew/public_html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#52 /home/andmorew/public_html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#53 /home/andmorew/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(151): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#54 /home/andmorew/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#55 /home/andmorew/public_html/index.php(43): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#56 {main}
Can you get into the backend of your OctoberCMS site?
If you can what are your component settings on the CMS page??
All else I would uninstall the Blog plugin. Check your PHP settings and make sure it is running php7.0+. Maybe increase the script execution time before installing plugins/updating plugins. Typically you would get a timeout error but I have seen some incomplete installations of plugins/modules/extensions on various platforms if the script execution time is too low.
The issue that I was encountering seems highly similar to the one described here: https://github.com/rainlab/blog-plugin/issues/451
and potentially fixed here:
https://github.com/rainlab/blog-plugin/pull/394
I was able (somehow?) to get the site back by editing the component and disabling (for now) a translation module.
As I am not 100% sure what I did, I consider the problem fixed, but not solved.
On to the next bug!
I have a production site using Database from an Amazon Server, I have two more sites on the same server and both of them connects without issues.
On this particular site the connection to mysql is not working, I thought that the env file was missing or not being see by the laravel app but is not the case, when I run php artisan tinker and try any command it works:
DB::table('categories')->get();
=> Illuminate\Support\Collection {#842
all: [
{#828
+"id": 1,
+"parent_id": null,
+"order": 1,
+"name": "Noticias",
+"slug": "noticias",
+"created_at": "2018-01-09 19:26:32",
+"updated_at": "2018-01-09 19:26:32",
},
],
}
The App::environment() method also works:
>>> App::environment();
=> "production"
The env files clearly says APP_DEBUG=false but it is returning a lot of debug, it is like the webserver is not reading the env file besides the artisan is.
This is driving me crazy because it started failing by itself, nothing was changed on the server or the code, it's the only project that is failing.
What else can I check?
[2018-08-25 12:22:04] production.ERROR: SQLSTATE[HY000] [2002] Connection refused {"exception":"[object] (PDOException(code: 2002): SQLSTATE[HY000] [2002] Connection refused at /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:67)
[stacktrace]
#0 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php(67): PDO->__construct('mysql:host=127....', 'root', 'C4f2469dcF!', Array)
#1 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php(43): Illuminate\\Database\\Connectors\\Connector->createPdoConnection('mysql:host=127....', 'root', 'C4f2469dcF!', Array)
#2 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Database/Connectors/MySqlConnector.php(24): Illuminate\\Database\\Connectors\\Connector->createConnection('mysql:host=127....', Array, Array)
#3 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectionFactory.php(183): Illuminate\\Database\\Connectors\\MySqlConnector->connect(Array)
#4 [internal function]: Illuminate\\Database\\Connectors\\ConnectionFactory->Illuminate\\Database\\Connectors\\{closure}()
#5 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Database/Connection.php(915): call_user_func(Object(Closure))
#6 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Database/Connection.php(940): Illuminate\\Database\\Connection->getPdo()
#7 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Database/Connection.php(399): Illuminate\\Database\\Connection->getReadPdo()
#8 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Database/Connection.php(325): Illuminate\\Database\\Connection->getPdoForSelect(true)
#9 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Database/Connection.php(657): Illuminate\\Database\\Connection->Illuminate\\Database\\{closure}('select * from `...', Array)
#10 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Database/Connection.php(624): Illuminate\\Database\\Connection->runQueryCallback('select * from `...', Array, Object(Closure))
#11 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Database/Connection.php(333): Illuminate\\Database\\Connection->run('select * from
`...', Array, Object(Closure))
#12 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(1719): Illuminate\\Database\\Connection->select('select
* from `...', Array, true)
#13 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(1704): Illuminate\\Database\\Query\\Builder->runSelect()
#14 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(483): Illuminate\\Database\\Query\\Builder->get(Array)
#15 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(467): Illuminate\\Database\\Eloquent\\Builder->getModels(Array)
#16 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(360): Illuminate\\Database\\Eloquent\\Builder->get(Array)
#17 /var/app/html/releases/20180824022105/app/Category.php(13): Illuminate\\Database\\Eloquent\\Model::all()
#18 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Cache/Repository.php(327): App\\Category::App\\{closure}()
#19 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Cache/CacheManager.php(304): Illuminate\\Cache\\Repository->remember('list-categories', NULL, Object(Closure))
#20 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(221): Illuminate\\Cache\\CacheManager->__call('remember', Array)
#21 /var/app/html/releases/20180824022105/app/Category.php(20): Illuminate\\Support\\Facades\\Facade::__callStatic('remember', Array)
#22 /var/app/html/releases/20180824022105/routes/web.php(150): App\\Category::getCategories()
#23 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Routing/Router.php(389): Illuminate\\Routing\\Router->{closure}(Object(Illuminate\\Routing\\Router))
#24 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Routing/Router.php(349): Illuminate\\Routing\\Router->loadRoutes(Object(Closure))
#25 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(221): Illuminate\\Routing\\Router->group(Array, Object(Closure))
#26 /var/app/html/releases/20180824022105/routes/web.php(162): Illuminate\\Support\\Facades\\Facade::__callStatic('group', Array)
#27 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Routing/Router.php(393): require('/var/www/turico...')
#28 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Routing/Router.php(349): Illuminate\\Routing\\Router->loadRoutes('/var/www/turico...')
#29 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Routing/RouteRegistrar.php(105): Illuminate\\Routing\\Router->group(Array, '/var/www/turico...')
#30 /var/app/html/releases/20180824022105/app/Providers/RouteServiceProvider.php(56): Illuminate\\Routing\\RouteRegistrar->group('/var/www/turico...')
#31 /var/app/html/releases/20180824022105/app/Providers/RouteServiceProvider.php(40): App\\Providers\\RouteServiceProvider->mapWebRoutes()
#32 [internal function]: App\\Providers\\RouteServiceProvider->map()
#33 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array)
#34 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#35 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\\Container\\BoundMethod::callBoundMethod(Object(Illuminate\\Foundation\\Application), Array, Object(Closure))
#36 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Container/Container.php(549): Illuminate\\Container\\BoundMethod::call(Object(Illuminate\\Foundation\\Application), Array, Array, NULL)
#37 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Foundation/Support/Providers/RouteServiceProvider.php(74): Illuminate\\Container\\Container->call(Array)
#38 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Foundation/Support/Providers/RouteServiceProvider.php(33): Illuminate\\Foundation\\Support\\Providers\\RouteServiceProvider->loadRoutes()
#39 /var/app/html/releases/20180824022105/app/Providers/RouteServiceProvider.php(28): Illuminate\\Foundation\\Support\\Providers\\RouteServiceProvider->boot()
#40 [internal function]: App\\Providers\\RouteServiceProvider->boot()
#41 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array)
#42 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#43 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\\Container\\BoundMethod::callBoundMethod(Object(Illuminate\\Foundation\\Application), Array, Object(Closure))
#44 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Container/Container.php(549): Illuminate\\Container\\BoundMethod::call(Object(Illuminate\\Foundation\\Application), Array, Array, NULL)
#45 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(792): Illuminate\\Container\\Container->call(Array)
#46 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(775): Illuminate\\Foundation\\Application->bootProvider(Object(App\\Providers\\RouteServiceProvider))
#47 [internal function]: Illuminate\\Foundation\\Application->Illuminate\\Foundation\\{closure}(Object(App\\Providers\\RouteServiceProvider), 26)
#48 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(776): array_walk(Array, Object(Closure))
#49 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/BootProviders.php(17): Illuminate\\Foundation\\Application->boot()
#50 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(213): Illuminate\\Foundation\\Bootstrap\\BootProviders->bootstrap(Object(Illuminate\\Foundation\\Application))
#51 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(162): Illuminate\\Foundation\\Application->bootstrapWith(Array)
#52 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(146): Illuminate\\Foundation\\Http\\Kernel->bootstrap()
#53 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))
#54 /var/app/html/releases/20180824022105/public/index.php(55): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
#55 {main}
"}
You should verify if you have bootstrap/cache/config.php file. If yes, it means, your config is cached. Than you can run:
php artisan config:cache
to refresh config and sync data you have set in .env or
php artisan config:clear
if you don't want to use cached config (keep in mind it's recommended to cache config on production)
The solution for me was to restart the laravel development server, ie: run php artisan serve again.
I had changed the db config after I had originally run the dev server.
I had a similar problem, I installed php7.2-mysql after I installed everything else. Tinker was working perfectly but my application would not connect.
I spent 2 hours trying to debug until a simple apache restart did the trick.
The problem is that mysql's root user can't be used anymore, since mysql v5.7. More about this here.
I've uploaded my laravel 5.6 project on Ubuntu 16.04.4.
When i upload my working project(API's tested on postman) on it, it returns a blank response and on the url it states "This page isn’t working" "HTTP ERROR 500".
From what I've learnt is that the php version of my project and is different from the one on the server.
My project is built on php 7.1.9 and the server php version is 7.1.18
Any form of help or information will be useful.
Thank you in advance
Log:
local.ERROR: syntax error, unexpected '?', expecting variable (T_VARIABLE) {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThr$
[stacktrace]
#0 /var/www/narcodes/vendor/composer/ClassLoader.php(322): Composer\\Autoload\\includeFile('/var/www/narcod...')
#1 [internal function]: Composer\\Autoload\\ClassLoader->loadClass('Symfony\\\\Compone...')
#2 /var/www/narcodes/vendor/laravel/framework/src/Illuminate/Routing/RouteCompiler.php(39): spl_autoload_call('Symfony\\\\Compone...')
#3 /var/www/narcodes/vendor/laravel/framework/src/Illuminate/Routing/Route.php(284): Illuminate\\Routing\\RouteCompiler->compile()
#4 /var/www/narcodes/vendor/laravel/framework/src/Illuminate/Routing/Route.php(261): Illuminate\\Routing\\Route->compileRoute()
#5 /var/www/narcodes/vendor/laravel/framework/src/Illuminate/Routing/RouteCollection.php(197): Illuminate\\Routing\\Route->matches(Object(Illuminate\\Http\\Request), t$
#6 [internal function]: Illuminate\\Routing\\RouteCollection->Illuminate\\Routing\\{closure}(Object(Illuminate\\Routing\\Route), 'api/user')
#7 /var/www/narcodes/vendor/laravel/framework/src/Illuminate/Support/Arr.php(175): call_user_func(Object(Closure), Object(Illuminate\\Routing\\Route), 'api/user')
#8 /var/www/narcodes/vendor/laravel/framework/src/Illuminate/Support/Collection.php(657): Illuminate\\Support\\Arr::first(Array, Object(Closure), NULL)
#9 /var/www/narcodes/vendor/laravel/framework/src/Illuminate/Routing/RouteCollection.php(198): Illuminate\\Support\\Collection->first(Object(Closure))
#10 /var/www/narcodes/vendor/laravel/framework/src/Illuminate/Routing/RouteCollection.php(164): Illuminate\\Routing\\RouteCollection->matchAgainstRoutes(Object(Illumin$
#11 /var/www/narcodes/vendor/laravel/framework/src/Illuminate/Routing/Router.php(619): Illuminate\\Routing\\RouteCollection->match(Object(Illuminate\\Http\\Request))
#12 /var/www/narcodes/vendor/laravel/framework/src/Illuminate/Routing/Router.php(608): Illuminate\\Routing\\Router->findRoute(Object(Illuminate\\Http\\Request))
#13 /var/www/narcodes/vendor/laravel/framework/src/Illuminate/Routing/Router.php(597): Illuminate\\Routing\\Router->dispatchToRoute(Object(Illuminate\\Http\\Request))
#14 /var/www/narcodes/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\\Routing\\Router->dispatch(Object(Illuminate\\Http\\Request))
#15 /var/www/narcodes/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}(O$
#16 /var/www/narcodes/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#17 /var/www/narcodes/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Fideloper\\Proxy\\TrustProxies->handle(Object(Illuminate\\Http\\Request), Obj$
#18 /var/www/narcodes/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illumina$
#19 /var/www/narcodes/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(31): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\$
#20 /var/www/narcodes/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Il$
#21 /var/www/narcodes/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illumina$
#22 /var/www/narcodes/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(31): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\$
#23 /var/www/narcodes/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Il$
#24 /var/www/narcodes/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illumina$
#25 /var/www/narcodes/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\$
#26 /var/www/narcodes/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle(Object(Ill$
#27 /var/www/narcodes/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illumina$
#28 /var/www/narcodes/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(51): Illuminate\\Routing\\Pipeline->Illuminate\\Ro$
#29 /var/www/narcodes/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode->handle(Obj$
#30 /var/www/narcodes/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illumina$
#31 /var/www/narcodes/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illumina$
#32 /var/www/narcodes/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(151): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#33 /var/www/narcodes/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Il$
#34 /var/www/narcodes/public/index.php(55): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
#35 {main}
"}
This error is because your php server version, can be different from what you see when doing php -v.
The right way to check this is to do a php info on your server side, not on CLI.
If you need to enable php 7.2 on apache this is the command on ubuntu
first disable old php version
sudo a2dismod php7.0
enable new version
sudo a2enmod php7.2
everyone
I have a website built with Laravel 5.4 (latest version) and I'm getting this "SuspiciousOperationException: Invalid Host error" on my logs many times a day. Even though it doesn't seem to be affecting my website's functionality, I'm worried it might be a symptom of some misconfiguration – and, at the very least, it's polluting my log files, making error tracking a little harder.
I've tried to figure out what's causing this on my own, but my lack of experience has shown… I have some idea of what might be causing this, but I have no confirmation of my theory and I have no clue of how to solve the issue.
The error message is the following:
[2017-08-03 23:47:03] production.ERROR: Symfony\Component\HttpFoundation\Exception\SuspiciousOperationException: Invalid Host "*.example.com". in /var/www/laravel/vendor/symfony/http-foundation/Request.php:1283
And the stack trace:
#0 /var/www/laravel/vendor/symfony/http-foundation/Request.php(1088): Symfony\Component\HttpFoundation\Request->getHost()
#1 /var/www/laravel/vendor/symfony/http-foundation/Request.php(1118): Symfony\Component\HttpFoundation\Request->getHttpHost()
#2 /var/www/laravel/vendor/symfony/http-foundation/Request.php(1815): Symfony\Component\HttpFoundation\Request->getSchemeAndHttpHost()
#3 /var/www/laravel/vendor/symfony/http-foundation/Request.php(1102): Symfony\Component\HttpFoundation\Request->prepareRequestUri()
#4 /var/www/laravel/vendor/symfony/http-foundation/Request.php(1867): Symfony\Component\HttpFoundation\Request->getRequestUri()
#5 /var/www/laravel/vendor/symfony/http-foundation/Request.php(985): Symfony\Component\HttpFoundation\Request->prepareBaseUrl()
#6 /var/www/laravel/vendor/symfony/http-foundation/Request.php(1933): Symfony\Component\HttpFoundation\Request->getBaseUrl()
#7 /var/www/laravel/vendor/symfony/http-foundation/Request.php(945): Symfony\Component\HttpFoundation\Request->preparePathInfo()
#8 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Http/Request.php(138): Symfony\Component\HttpFoundation\Request->getPathInfo()
#9 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Routing/Matching/UriValidator.php(19): Illuminate\Http\Request->path()
#10 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Routing/Route.php(259): Illuminate\Routing\Matching\UriValidator->matches(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#11 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Routing/RouteCollection.php(193): Illuminate\Routing\Route->matches(Object(Illuminate\Http\Request), true)
#12 [internal function]: Illuminate\Routing\RouteCollection->Illuminate\Routing\{closure}(Object(Illuminate\Routing\Route), 'api/user')
#13 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Support/Arr.php(175): call_user_func(Object(Closure), Object(Illuminate\Routing\Route), 'api/user')
#14 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Routing/RouteCollection.php(194): Illuminate\Support\Arr::first(Array, Object(Closure))
#15 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Routing/RouteCollection.php(164): Illuminate\Routing\RouteCollection->matchAgainstRoutes(Array, Object(Illuminate\Http\Request))
#16 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Routing/Router.php(548): Illuminate\Routing\RouteCollection->match(Object(Illuminate\Http\Request))
#17 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Routing/Router.php(527): Illuminate\Routing\Router->findRoute(Object(Illuminate\Http\Request))
#18 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Routing/Router.php(513): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#19 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#20 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))
#21 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(30): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#22 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#23 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#24 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(30): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#25 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#26 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#27 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#28 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle(Object(Illuminate\Http\Request), Object(Closure))
#29 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#30 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(46): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#31 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))
#32 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#33 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#34 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#35 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#36 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#37 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(Illuminate\Http\Request), Object(Closure))
#38 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#39 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(59): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#40 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure))
#41 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#42 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#43 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(151): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#44 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#45 /var/www/laravel/public/index.php(53): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#46 {main}
The configuration data that I think might be related is as follows:
.env:
APP_URL=example.com
(I've tried a few other values like the ones below:)
http://www.example.com
http://*.example.com
config/app:
'url' => env('APP_URL', 'example.dev')
My website works on both http://example.com and http://www.example.com ; I've noticed that sessions aren't shared between them, but everything else is the same.
Any help solving this issue would be much appreciated. Thank you in advance!
EDIT: redacted the domain name
I had the same issue, but for me removing the wildcard from my nginx server_name directive wasn't an option. (My website depends on dynamic subdomain routing).
The problem is related to PHP variable $_SERVER['SERVER_NAME'] not being set correctly by nginx when there is a wildcard in the server_name. To fix it, you have to add the following in your nginx config:
fastcgi_param SERVER_NAME $host
For example:
location ~ \.php$ {
...
fastcgi_param SERVER_NAME $host
...
}
I've finally tracked down what was causing this: it was nginx's configuration.
I had configured my server's server_name directive as *.example.com – which is a valid wildcard name for the directive, as seen at http://nginx.org/en/docs/http/server_names.html , but doesn't seem to play well with Laravel. I haven't had this exception be thrown since I changed the value to example.com www.example.com a couple of days ago, so this definitely seemed to do the trick.