skip to Main Content

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' => IlluminateSupportFacadesRedis::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


  1. 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.

    Login or Signup to reply.
  2. In .end file, please put REDIS_HOST=redis-master which is your redis container name.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search