Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

kosmoskosmos's avatar

*SOLVED* Redis Cache `AUTH` failed; But Predis is abled to connect.

This is solved. Port numbers were messed up Oo

Hi there, we're trying to run a Redis-cached Laravel Application on a distributed heroku-system. We figured out the following tutorial could help us: http://martinbean.co.uk/blog/2015/12/12/using-heroku-redis-with-laravel-5/

.env has

REDIS_URL=redis://h:[email protected]:6939

so we configured the config/database.php basically as following (which is correctly parsed from the string above)

    'redis' => [
        'cluster' => false,
        'default' => [
            'host'     => 'some.example.com',
            'port'     => 6379,
            'username' =>' h',
            'password' => 'secret'
            'database' => env('REDIS_DATABASE', 0),
        ],

For testing I made two routes:

Route::get("/rtf","HomeController@redistestfailing");
Route::get("/rtw","HomeController@redistestworking");

Which leads to the following controller methods:

   // a: this fails
    public function redistestfailing(){
        var_dump(Redis::get("test"));
        var_dump(Redis::set('test',date("d.m.Y H:i:s")));        
    }
   // b: this succeeds
    public function redistestworking(){
        $redis = new Predis\Client(env('REDIS_URL'));
        var_dump($redis->get("test"));
        var_dump($redis->set('test',date("d.m.Y H:i:s")));        
    }

In my understanding function a and b should connect the same way, or at least similary, since both rely on Predis\Client at the end...

Since b works like a charm, returning something like this

string '04.10.2016 22:25:59' (length=19) object(Predis\Response\Status)[487] private 'payload' => string 'OK' (length=2)

Method a (and also the Cache-facade) throws this exception:

ConnectionException in AbstractConnection.php line 155: AUTH failed: ERR invalid password [tcp://ec2-54-75-239-105.eu-west-1.compute.amazonaws.com:6379] in AbstractConnection.php line 155 at AbstractConnection->onConnectionError('AUTH failed: ERR invalid password', '0') in StreamConnection.php line 263 at StreamConnection->connect() in AbstractConnection.php line 180 at AbstractConnection->getResource() in StreamConnection.php line 288 at StreamConnection->write('*2 $3 GET $4 test ') in StreamConnection.php line 394 at StreamConnection->writeRequest(object(StringGet)) in AbstractConnection.php line 110 at AbstractConnection->executeCommand(object(StringGet)) in Client.php line 331 ...

As you might ask: "Did you enter the password correctly?" I can already reply "yes, it is parsed correctly and it is also taken way down into the methods of AbstractConnection" – at some point my knowledge about those connection types fade to work, but IMHO, this is no problem with my connection request rather than a bug in one of those Facades / Accessors? Has anyone got any idea with this / good questions / hints?

Best, Andreas

0 likes
0 replies

Please or to participate in this conversation.