untymage's avatar

Lumen phpredis 'Connection refused'

I want to use phpredis extension in my lumen project but i cant get it to work:

composer require illuminate/redis

.env

REDIS_CLIENT=phpredis
CACHE_DRIVER=redis

app.php

$app->register(Illuminate\Redis\RedisServiceProvider::class);

database.php

'redis' => [

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

    'options' => [
        'cluster' => env('REDIS_CLUSTER', 'phpredis'),
        'prefix' => Str::slug(env('APP_NAME', 'laravel'), '_').'_database_',
    ],

    '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),
    ],

],

i can see redis extension in phpinfo() https://i.imgur.com/VJ8mx8n.jpg

But when i use cache facade it not working:

Illuminate\Support\Facades\Cache::get('test')
// RedisException with message 'Connection refused'

I tried to change Redis facade alias name in app.php:

if (! class_exists('Redis')) {
    class_alias('Illuminate\Support\Facades\Redis', 'RedisManager');
}

But i have the same error

0 likes
0 replies

Please or to participate in this conversation.