0
votes

This is the first time for me to setup the laravel server with redis. PHP artisan migrate worked OK and successfully setup DB tables. However, I noticed the following errors have been keep recorded (about every 10 secs!) on laravel.log. It is very strange as nobody is accessing the site yet. I checked the password and the host name in .env many times. Any idea?

local.ERROR: SQLSTATE[HY000] [2002] Connection refused (SQL: select * from sessions where id = xxxxx limit 1) {"exception":"[object] (Illuminate\Database\QueryException(code: 2002): SQLSTATE[HY000] [2002] Connection refused (SQL: select * from sessions where id = xxxx limit 1) at /var/www/html/web/vendor/laravel/framework/src/Illuminate/Database/Connection.php:671 [stacktrace] ... local.ERROR: Debugbar exception: SQLSTATE[HY000] [2002] Connection refused (SQL: select * from sessions where id = xxxxx limit 1)

.env

DB_CONNECTION=mysql
DB_HOST=hostname
DB_PORT=3306
DB_DATABASE=dbname
DB_USERNAME=username
DB_PASSWORD=pass

BROADCAST_DRIVER=log
CACHE_DRIVER=redis
QUEUE_CONNECTION=sync
SESSION_DRIVER=redis
SESSION_LIFETIME=120

REDIS_HOST=hostname
REDIS_PASSWORD=null
REDIS_PORT=6379
REDIS_CLIENT=phpredis

...
DEBUGBAR_ENABLED=false

database.php

'redis' => [

    'client' => env('REDIS_CLIENT', 'phpredis'),

    'default' => [
        'host' => env('REDIS_HOST', '127.0.0.1'),
        'password' => env('REDIS_PASSWORD', null),
        'port' => env('REDIS_PORT', '6379'),
        'database' => env('REDIS_DB', '0'),
    ],

    'cache' => [
        'host' => env('REDIS_HOST', '127.0.0.1'),
        'password' => env('REDIS_PASSWORD', null),
        'port' => env('REDIS_PORT', '6379'),
        'database' => env('REDIS_CACHE_DB', '1'),
    ],

],
1

1 Answers

0
votes

Turned out the default .env was used from "something" triggering above error. ".env.prd " was what I was expecting to be used (of course I did check with artisan if .env.prd is used). I modified bootstrap/app.php and made .env.prd default and now it stopped generating error.