mardi 17 mars 2020

Get php_network_getaddresses: getaddrinfo failed: Name or service not known in laravel 5.8

I get the following error when I upload my app to my hosting.

SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known (SQL: select * from `sessions` left join `proyek` as `p` on `p`.`id_proyek` = `sessions`.`project_id` where `user_id` is null limit 1)

I don't know why this error comes up while in my localhost works well. I believe that it is caused by $session = Session::where('user_id', Auth::id())->first(); in AppServiceProvider.php. I know it because when I commented it out, the app is working well. Here is the code:

    <?php
    // app/Providers/AppServiceProvider.php

    namespace App\Providers;

    use App\Models\Session;

    use Illuminate\Support\Facades\Auth;
    use Illuminate\Support\ServiceProvider;

    class AppServiceProvider extends ServiceProvider
    {
        /**
         * Bootstrap any application services.
         *
         * @return void
         */
        public function boot()
        {

            view()->composer('*', function ($view) {

                $session = Session::where('user_id', Auth::id())->first();

                $view->with('active_project', $session);
            });
        }

        /**
         * Register any application services.
         *
         * @return void
         */
        public function register()
        {
            //
        }
    }

I have tried to run php artisan config:clear, php artisan cache:clear but still get it.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire