2

This project was set up by another team and I'm unable to get passed this one error. Using PHP 7.2 and Laravel 6.2. My docker-compose.yml:

redis:
    image: redis
    command: ["redis-server", "--appendonly", "yes","--requirepass","Redis.123"]
    volumes:
      - redis-data:/data
    container_name: redis-master
    ports:
      - "6379:6379"

and database.php:

'redis' => [

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

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

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

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

    ]

The container is up and running and "Ready to accept connections". This error is in my stack trace if I attempt to hit the base url or any endpoints. I have aliased redis in app.php: 'RedisManager' => Illuminate\Support\Facades\Redis::class, as others have recommended. Can anyone see anything obvious that is missing or could cause this? Predis is installed in the composer.json: "predis/predis": "^1.1",, but not set in the config. If I changed phpredis to predis I get the error development.ERROR:SELECTfailed: NOAUTH Authentication required. [tcp://127.0.0.1:6379].

2 Answers 2

2

The error you get when you set to phpredis, it is most likely related to phpredis extension. You need to install this extension if you want to use phpredis client.

The error you get when you set it to predis is totally different. It is authentication error because you didn't set password. In your .env file, append this

REDIS_PASSWORD=Redis.123

Then artisan config:clear, it could do the work.

Sign up to request clarification or add additional context in comments.

3 Comments

I'm using envkey for my .env and the REDIS_PASSWORD in there is null, so I'm guessing phpredis was intended. I checked and I have redis in my php.ini correctly: php -r "if (new Redis() == true){ echo \"\r\n OK \r\n\"; }" returns OK and php -i | grep Redis looks good as well: Redis Support => enabled Redis Version => 5.2.2 Redis Sentinel Version => 0.1. I also have extension="redis.so" at the top of my php7.2.ini and have restarted php7.2 with brew services restart [email protected].
what happens if you set phpredis as REDIS_CLIENT with the set password as i offered in the answer ? Do you get any error or it works ? @MattLarson
I ended up doing a full reboot and phpredis was working, but ended up needing the REDIS_PASSWORD anyway, so added that to envkey. Thanks!
0

In .end file, please put REDIS_HOST=redis-master which is your redis container name.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.