Predis is giving 'Error while reading line from server'

Active3 hr before
Viewed126 times

7 Answers


I am using predis, it's subscribed to a channel and listening. It throws the following error (below) and dies after 60 secs exactly. It's surely not my web servers error or its timeout.,How we got to know about this problem ? In php, we were getting "Cannot assign requested address" error while creating a socket (error code 99)., Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers , Stack Overflow Public questions & answers

Just set the read_write_timeout connection parameter to 0 or -1 to fix this. e.g.

$redis = new Predis\ Client('tcp://'.
load more v

First I am not sure this is a lumen specific error or a Laravel error too. I have an app running on laravel (5.1) which dispatch jobs, handled by a lumen (5.1) worker.,You may also need to ensure you have the scheme set to tls if appropriate.,I had the same problem. Solved it by installing redis-server on ubuntu, and then starting it using redis-cli ping, Learning Lab →

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

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

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

Predis\Connection\ConnectionException: Error while reading line from the server. [tcp://redis:6379] in Predis\Connection\AbstractConnection->onConnectionError() (line 168 of /var/www/mysite/sites/all/libraries/predis/src/Connection/AbstractConnection.php).,we are also facing similar errors : ,I'm sorry but since there never was anymore information, I'll close this. Feel free to reopen it if you experience any more problems or have more information to provide. Thank you.,Services, Training & Hosting

I think this might be affected by the Predis read_write_timeout parameter, but there is no way to modify that at the moment.


I am using predis and its subscribed to a channel and listening, it throws the error and die , shown below, after 60 secs exaxtly, its surely not my web server error or its timeout. ,Also if i keep using (send data to it and it processes) the worker it doesn't give any error. So its likely a timeout somewhere, and that too in connection.,Setting connection parameters is documented in the README. The author of Redis noted the relevance of the read_write_timeout parameter to this error in an issue on GitHub, in which he notes that:,RedisArray provides consistent hashing and you can select which part of the key is to be used for the distribution.

Here is my code snippet, which is likely producing error, because if data is given to worker it runs this code and go forward, which produces no error after that.

$pubsub = $redis - > pubSub();
$pubsub - > subscribe($channel1);

foreach($pubsub as $message) { //doing stuff here and unsubscribing from channel


PHP Fatal error: Uncaught exception 'PredisNetworkConnectionException'
with message 'Error while reading line from the server' in Predis / Network / ConnectionBase.php: 159 Stack trace:
   #0 library/vendor/predis/lib/Predis/Network/StreamConnection.php(195): PredisNetworkConnectionBase->onConnectionError('Error while rea...')
# 1 library / vendor / predis / lib / Predis / PubSub / PubSubContext.php(259): PredisNetworkStreamConnection - > read()
#2 library/vendor/predis/lib/Predis/PubSub/PubSubContext.php(206): PredisPubSubPubSubContext->getValue()
# 3 pdf / file.php(16): PredisPubSubPubSubContext - > current()
#4 {main}   thrown in Predis/Network/ConnectionBase.php on line 159
load more v

I want to init redis client , and i can init success by other language , but i init failed by predis.,i want to connect redis and this redis on the Azure,Code sample If applicable, a small snippet of code that reproduces the issue.,@nrk hi could you please give some advice?

$client = new Client([
   'scheme' => 'tcp',
   'host' => 'xxx',
   'port' => 6380,
   'password' => 'xx',
   'read_write_timeout' => 0,

// var_dump($client);

$res = $client - > ping(null);

$tileX = 1;
$tileY = 2;
$tileZ = 7;

$key = $app['env'].
$filed = $tileX.
$count = $client - > hget($key, $filed);

if ($count == null) {
   $count = 1;
} else {
$client - > hset($key, $filed, $count);

PredisConnectionConnectionException Error while reading line from the server. [tcp://],I’ve been trying to deploy a Laravel application using Forge for a while now, but I always get stuck on Predis giving me the following error:, Laravel Vue Component not Loading in Browser,Hey any fix since you’ve posted this? trying to run pixelfed on my pi and i’m getting the exact same error.

I’ve been trying to deploy a Laravel application using Forge for a while now, but I always get stuck on Predis giving me the following error:

Error while reading line from the server. [tcp://]

while reading line from the server.[tcp: //]
load more v

Laravel 5.2 Controller-Why do I get an error when creating a controller from the command line?,androidStudio: ERROR: Error occurred while communicating with CMake server.,Laravel install predis extension,Fix NGINX 502 error: Upstream Sent Too Big Header While Reading Response Header from Upstream

Laravel explains Redis in the documentation and subscription case, command line runs PHP Artisan Redis: Subscribe to 60S automatic disconnection and error

 [Predis\ Connection\ ConnectionException]
 while reading line from the server.[tcp: //]
'redis' => [

   'cluster' => false,

   'default' => [
      'host' => env('REDIS_HOST', ''),
      'password' => env('REDIS_PASSWORD', null),
      'port' => env('REDIS_PORT', 6379),
      'database' => 0,
      'read_write_timeout' => 0, //new

load more v

Other "error-undefined" queries related to "Predis is giving 'Error while reading line from server'"