title: Laravel Queue via Redis: local.ERROR: read error on connection to 127.0.0.1:6379
body: <p>Im trying to run the laravel queue via redis connection and after a few seconds when the worker starts I get the following errors.</p>
  <p>Queue command:</p>
  <pre><code>$&gt; php artisan queue:work --tries=1 --queue=test_queue
  </code></pre>
  <p>Errors:</p>
  <pre><code>local.ERROR: read error on connection to 127.0.0.1:6379 {&quot;exception&quot;:&quot;[object] (RedisException(code: 0): read error on connection to 127.0.0.1:6379 at vendor\\laravel\\framework\\src\\Illuminate\\Redis\\Connections\\Connection.php:116)
  [stacktrace]
  #0 vendor\\laravel\\framework\\src\\Illuminate\\Redis\\Connections\\Connection.php(116): Redis-&gt;blPop(Array, 0)
  #1 vendor\\laravel\\framework\\src\\Illuminate\\Redis\\Connections\\PhpRedisConnection.php(440): Illuminate\\Redis\\Connections\\Connection-&gt;command('blpop', Array)
  #2 vendor\\laravel\\framework\\src\\Illuminate\\Redis\\Connections\\PhpRedisConnection.php(179): Illuminate\\Redis\\Connections\\PhpRedisConnection-&gt;command('blpop', Array)
  #3 vendor\\laravel\\framework\\src\\Illuminate\\Queue\\RedisQueue.php(233): Illuminate\\Redis\\Connections\\PhpRedisConnection-&gt;blpop(Array, 0)
  #4 vendor\\laravel\\framework\\src\\Illuminate\\Queue\\RedisQueue.php(169): Illuminate\\Queue\\RedisQueue-&gt;retrieveNextJob('queues:test_queue')
  #5 vendor\\laravel\\framework\\src\\Illuminate\\Queue\\Worker.php(270): Illuminate\\Queue\\RedisQueue-&gt;pop('test_queue')
  #6 vendor\\laravel\\framework\\src\\Illuminate\\Queue\\Worker.php(123): Illuminate\\Queue\\Worker-&gt;getNextJob(Object(Illuminate\\Queue\\RedisQueue), 'test_queue')
  #7 vendor\\laravel\\framework\\src\\Illuminate\\Queue\\Console\\WorkCommand.php(112): Illuminate\\Queue\\Worker-&gt;daemon('redis', 'test_queue', Object(Illuminate\\Queue\\WorkerOptions))
  #8 vendor\\laravel\\framework\\src\\Illuminate\\Queue\\Console\\WorkCommand.php(96): Illuminate\\Queue\\Console\\WorkCommand-&gt;runWorker('redis', 'test_queue')
  #9 [internal function]: Illuminate\\Queue\\Console\\WorkCommand-&gt;handle()
  #10 vendor\\laravel\\framework\\src\\Illuminate\\Container\\BoundMethod.php(32): call_user_func_array(Array, Array)
  #11 vendor\\laravel\\framework\\src\\Illuminate\\Container\\Util.php(36): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
  #12 vendor\\laravel\\framework\\src\\Illuminate\\Container\\BoundMethod.php(90): Illuminate\\Container\\Util::unwrapIfClosure(Object(Closure))
  #13 vendor\\laravel\\framework\\src\\Illuminate\\Container\\BoundMethod.php(34): Illuminate\\Container\\BoundMethod::callBoundMethod(Object(Illuminate\\Foundation\\Application), Array, Object(Closure))
  #14 vendor\\laravel\\framework\\src\\Illuminate\\Container\\Container.php(590): Illuminate\\Container\\BoundMethod::call(Object(Illuminate\\Foundation\\Application), Array, Array, NULL)
  #15 vendor\\laravel\\framework\\src\\Illuminate\\Console\\Command.php(201): Illuminate\\Container\\Container-&gt;call(Array)
  #16 vendor\\symfony\\console\\Command\\Command.php(255): Illuminate\\Console\\Command-&gt;execute(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle))
  #17 vendor\\laravel\\framework\\src\\Illuminate\\Console\\Command.php(188): Symfony\\Component\\Console\\Command\\Command-&gt;run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle))
  #18 vendor\\symfony\\console\\Application.php(1012): Illuminate\\Console\\Command-&gt;run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
  #19 vendor\\symfony\\console\\Application.php(272): Symfony\\Component\\Console\\Application-&gt;doRunCommand(Object(Illuminate\\Queue\\Console\\WorkCommand), Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
  #20 vendor\\symfony\\console\\Application.php(148): Symfony\\Component\\Console\\Application-&gt;doRun(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
  #21 vendor\\laravel\\framework\\src\\Illuminate\\Console\\Application.php(93): Symfony\\Component\\Console\\Application-&gt;run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
  #22 vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Console\\Kernel.php(131): Illuminate\\Console\\Application-&gt;run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
  #23 artisan(37): Illuminate\\Foundation\\Console\\Kernel-&gt;handle(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
  #24 {main}
  &quot;}
  </code></pre>
  <p>Here is the queue config:</p>
  <pre><code>'redis' =&gt; [
      'driver' =&gt; 'redis',
      'connection' =&gt; 'laravel_queues',
      'queue' =&gt; env('REDIS_QUEUE', 'default'),
      'retry_after' =&gt; 190, 
      'block_for' =&gt; 0,
  ],
  </code></pre>
  <p>Here is the connection config:</p>
  <pre><code>'laravel_queues' =&gt; [
      'host' =&gt; env('REDIS_HOST', 'localhost'),
      'password' =&gt; env('REDIS_PASSWORD', null),
      'port' =&gt; env('REDIS_PORT', '6379'),
      'database' =&gt; 2,
  ],
  </code></pre>
  <hr />
  <p><strong>Edit 1</strong></p>
  <p>Redis Server is Up &amp; Running and works fine for everything else:</p>
  <p><a href="https://i.stack.imgur.com/QMqc4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QMqc4.png" alt="enter image description here" /></a></p>
  <p><a href="https://i.stack.imgur.com/aSwwT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aSwwT.png" alt="enter image description here" /></a></p>
  <hr />
  <p><strong>Edit 2</strong></p>
  <p>As suggested, ive run <code>monitor</code> on CLI and this is what happens:</p>
  <pre><code>1596784000.713047 [2 127.0.0.1:62141] &quot;EVAL&quot; &quot;-- Get all of the jobs with an expired \&quot;score\&quot;...\nlocal val = redis.call('zrangebyscore', KEYS[1], '-inf', ARGV[1])\n\n-- If we have values in the array, we will remove them from the first queue\n-- and add them onto the destination queue in chunks of 100, which moves\n-- all of the appropriate jobs onto the destination queue very safely.\nif(next(val) ~= nil) then\n    redis.call('zremrangebyrank', KEYS[1], 0, #val - 1)\n\n    for i = 1, #val, 100 do\n        redis.call('rpush', KEYS[2], unpack(val, i, math.min(i+99, #val)))\n        -- Push a notification for every job that was migrated...\n        for j = i, math.min(i+99, #val) do\n            redis.call('rpush', KEYS[3], 1)\n        end\n    end\nend\n\nreturn val&quot; &quot;3&quot; &quot;LOCALHOSTqueues:test_queue:delayed&quot; &quot;LOCALHOSTqueues:test_queue&quot; &quot;LOCALHOSTqueues:test_queue:notify&quot; &quot;1596784000&quot;
  1596784000.713180 [2 lua] &quot;zrangebyscore&quot; &quot;LOCALHOSTqueues:test_queue:delayed&quot; &quot;-inf&quot; &quot;1596784000&quot;
  1596784000.713362 [2 127.0.0.1:62141] &quot;EVAL&quot; &quot;-- Get all of the jobs with an expired \&quot;score\&quot;...\nlocal val = redis.call('zrangebyscore', KEYS[1], '-inf', ARGV[1])\n\n-- If we have values in the array, we will remove them from the first queue\n-- and add them onto the destination queue in chunks of 100, which moves\n-- all of the appropriate jobs onto the destination queue very safely.\nif(next(val) ~= nil) then\n    redis.call('zremrangebyrank', KEYS[1], 0, #val - 1)\n\n    for i = 1, #val, 100 do\n        redis.call('rpush', KEYS[2], unpack(val, i, math.min(i+99, #val)))\n        -- Push a notification for every job that was migrated...\n        for j = i, math.min(i+99, #val) do\n            redis.call('rpush', KEYS[3], 1)\n        end\n    end\nend\n\nreturn val&quot; &quot;3&quot; &quot;LOCALHOSTqueues:test_queue:reserved&quot; &quot;LOCALHOSTqueues:test_queue&quot; &quot;LOCALHOSTqueues:test_queue:notify&quot; &quot;1596784000&quot;
  1596784000.713563 [2 lua] &quot;zrangebyscore&quot; &quot;LOCALHOSTqueues:test_queue:reserved&quot; &quot;-inf&quot; &quot;1596784000&quot;
  1596784000.713972 [2 127.0.0.1:62141] &quot;EVAL&quot; &quot;-- Pop the first job off of the queue...\nlocal job = redis.call('lpop', KEYS[1])\nlocal reserved = false\n\nif(job ~= false) then\n    -- Increment the attempt count and place job on the reserved queue...\n    reserved = cjson.decode(job)\n    reserved['attempts'] = reserved['attempts'] + 1\n    reserved = cjson.encode(reserved)\n    redis.call('zadd', KEYS[2], ARGV[1], reserved)\n    redis.call('lpop', KEYS[3])\nend\n\nreturn {job, reserved}&quot; &quot;3&quot; &quot;LOCALHOSTqueues:test_queue&quot; &quot;LOCALHOSTqueues:test_queue:reserved&quot; &quot;LOCALHOSTqueues:test_queue:notify&quot; &quot;1596784190&quot;
  1596784000.714130 [2 lua] &quot;lpop&quot; &quot;LOCALHOSTqueues:test_queue&quot;
  1596784000.714340 [2 127.0.0.1:62141] &quot;BLPOP&quot; &quot;LOCALHOSTqueues:test_queue:notify&quot; &quot;0&quot;
  </code></pre>