Search code examples
laravelredispredisphpredis

How to Resolve Predis Connection Timeout


i'm using predis integrated with laravel, in some case predis got connection timeout, but when i'm trying to connect redis server via cli, i got connected perfectly

can anyone help me how to resolve it ?

Predis\Connection\ConnectionException {#7222-connection: Predis\Connection\StreamConnection {#7171
-resource: null
-cachedId: null
#parameters: Predis\Connection\Parameters {#7178
  -parameters: array:5 [
    "host" => "Host"
    "password" => "Password"
    "port" => "6379"
    "database" => 0
    "scheme" => "tcp"
  ]
}
#initCommands: array:1 [
  0 => Predis\Command\RawCommand {#7218
    -slot: null
    -commandID: "SELECT"
    -arguments: array:1 [
      0 => 0
    ]
  }
]}#message: "Connection timed out [tcp://Host:6379]" #code: 110 #file:"./vendor/predis/predis/src/Connection/AbstractConnection.php" #line: 155

Any help will be greatly appreciated!


Solution

  • As you can see in the debug data your Host is set to Host. I'm assuming you got redis on a localhost setup, in your .env file set the following variable. Also your password seems off, adjust that also, most local redis installs has a blank password.

    REDIS_HOST=127.0.0.1
    REDIS_PASSWORD=
    

    If you got redis on a server, set your ip accordingly.