{"id":"ea3ae5a84264d771","repo":"laravel/framework","slug":"redis-error-s","errorCode":null,"errorMessage":"Redis error: %s.","messagePattern":"Redis error: (.+?)\\.","errorType":"exception","errorClass":"BroadcastException","httpStatus":null,"severity":"error","filePath":"src/Illuminate/Broadcasting/Broadcasters/RedisBroadcaster.php","lineNumber":157,"sourceCode":"                    $connection->client()->getClientBy('slot', mt_rand(0, 16383))\n                );\n\n                if ($events = $connection->getEventDispatcher()) {\n                    $randomClusterNodeConnection->setEventDispatcher($events);\n                }\n\n                $randomClusterNodeConnection->eval(\n                    $this->broadcastMultipleChannelsScript(),\n                    0, $payload, ...$this->formatChannels($channels)\n                );\n            } else {\n                $connection->eval(\n                    $this->broadcastMultipleChannelsScript(),\n                    0, $payload, ...$this->formatChannels($channels)\n                );\n            }\n        } catch (ConnectionException|RedisException $e) {\n            throw new BroadcastException(\n                sprintf('Redis error: %s.', $e->getMessage())\n            );\n        }\n    }\n\n    /**\n     * Get the Lua script for broadcasting to multiple channels.\n     *\n     * ARGV[1] - The payload\n     * ARGV[2...] - The channels\n     *\n     * @return string\n     */\n    protected function broadcastMultipleChannelsScript()\n    {\n        return <<<'LUA'\nfor i = 2, #ARGV do\n  redis.call('publish', ARGV[i], ARGV[1])","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/laravel/framework/blob/bd6b5437e6ad87bb49f9b426724f07a9f64e9683/src/Illuminate/Broadcasting/Broadcasters/RedisBroadcaster.php#L139-L175","documentation":"RedisBroadcaster::broadcast() catches Predis ConnectionException or a phpredis RedisException raised while publishing to the Redis pub/sub channel and re-throws as BroadcastException with the underlying message. It signals the Redis connection backing the broadcaster is unreachable or erroring.","triggerScenarios":"Calling broadcast() when the Redis server is down, unreachable, refuses auth, or when the configured broadcast connection name maps to a non-existent Redis connection. Also triggered by a Lua eval failure on cluster nodes.","commonSituations":"REDIS_HOST/REDIS_PORT/REDIS_PASSWORD wrong in .env. Redis service not started in dev. Docker/SSH tunnel to Redis dropped. Using a Redis cluster without all nodes reachable. The 'broadcasting' => 'redis' connection in config/broadcasting.php references a missing redis connection.","solutions":["Check the Redis connection defined under 'redis' in config/database.php and ensure REDIS_HOST/PORT/PASSWORD are correct.","Verify redis-cli can connect with the same credentials from the app host.","Ensure config/broadcasting.php 'connections.redis.connection' points to a defined Redis connection.","Restart the Redis server / reconnect the tunnel, then retry the broadcast."],"exampleFix":"// before\n'redis' => [\n    'driver' => 'redis',\n    'connection' => 'default',\n],\n// .env has a wrong REDIS_PORT\n\n// after\n// .env\nREDIS_HOST=127.0.0.1\nREDIS_PORT=6379\nREDIS_PASSWORD=null\n// verify with: redis-cli -h 127.0.0.1 -p 6379 ping","handlingStrategy":"retry","validationCode":"// Health-check the Redis connection before broadcasting\n$redis = app('redis')->connection(config('broadcasting.connections.redis.connection'));\ntry {\n    $redis->ping();\n} catch (\\RedisException|\\Predis\\Connection\\ConnectionException $e) {\n    throw new \\RuntimeException('Redis unreachable, cannot broadcast: '.$e->getMessage());\n}","typeGuard":"// n/a - infrastructure error","tryCatchPattern":"try {\n    broadcast(new OrderShipped($order));\n} catch (\\Illuminate\\Broadcasting\\BroadcastException $e) {\n    if (str_starts_with($e->getMessage(), 'Redis error')) {\n        // schedule retry, alert ops\n    }\n    throw $e;\n}","preventionTips":["Run a local Redis in dev matching production settings.","Use a connection with sensible timeouts.","Monitor Redis connectivity in health checks.","Keep broadcast payload small to avoid Lua eval timeouts."],"tags":["broadcasting","redis","network","configuration"],"analyzedSha":"bd6b5437e6ad87bb49f9b426724f07a9f64e9683","analyzedAt":"2026-08-06T00:28:32.783Z","schemaVersion":2}