{"record":{"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/e0f6eb3518ac29fbbca8529e97d0df7fc9f24481/src/Illuminate/Broadcasting/Broadcasters/RedisBroadcaster.php#L139-L175","documentation":"RedisBroadcaster::broadcast executes a Lua script over the Redis connection to fan a payload out to multiple channels. If the Redis connection raises a ConnectionException or RedisException (from the predis/predis or phpredis extension), it is wrapped into a BroadcastException with the original Redis error message. This isolates transport-level Redis failures behind Laravel's broadcasting abstraction.","triggerScenarios":"Calling broadcast()/event() while the configured REDIS_HOST/REDIS_PORT is unreachable, REDIS_PASSWORD is wrong, the Redis server is maxed on memory (OOM during EVAL), or the phpredis/predis client times out on a slow cluster node. Specifically occurs in the broadcastMultipleChannelsScript eval path.","commonSituations":"REDIS_PASSWORD mismatch between Laravel and the Redis server (common on managed Redis like Upstash/Redis Cloud after rotation). Using a Redis Cluster URL but config/database.php has 'cluster' => false. Lua script blocked by Redis 'no scripts' configuration (e.g., AWS ElastiCache with parameter group restrictions). Network partitions to Redis during high traffic.","solutions":["Verify REDIS_HOST, REDIS_PORT, REDIS_PASSWORD, and the 'database' cache/queue/broadcast connection block in config/database.php match the Redis server.","For Redis Cluster, ensure 'cluster' => true (or use 'redis_clusters' / 'clusters' options) so the randomClusterNodeConnection branch is exercised instead of failing on a single-node assumption.","Catch \\Illuminate\\Broadcasting\\BroadcastException and inspect the chained Redis exception via getPrevious() to triage OOM vs auth vs network.","Check Redis server logs for 'OOM command not allowed' or 'NOSCRIPT' errors if the EVAL call repeatedly fails."],"exampleFix":"// before\nbroadcast(new OrderShipped($order));\n\n// after\nuse Illuminate\\Broadcasting\\BroadcastException;\n\ntry {\n    broadcast(new OrderShipped($order));\n} catch (BroadcastException $e) {\n    $redisCause = $e->getPrevious();\n    logger()->error('Redis broadcast failed', [\n        'message' => $redisCause?->getMessage(),\n        'order_id' => $order->id,\n    ]);\n    throw $e;\n}","handlingStrategy":"try-catch","validationCode":"// Validate Redis connectivity before broadcasting in long-running processes\n$redis = Cache::store('redis')->getRedis();\nif (! $redis->ping()) {\n    throw new \\RuntimeException('Redis unreachable; cannot broadcast.');\n}","typeGuard":null,"tryCatchPattern":"use Illuminate\\Broadcasting\\BroadcastException;\n\ntry {\n    broadcast($event);\n} catch (BroadcastException $e) {\n    $cause = $e->getPrevious();\n    if ($cause instanceof \\Redis\\ConnectionException\n        || $cause instanceof \\Predis\\Connection\\ConnectionException) {\n        // network-level failure: queue for retry\n        dispatch(new RetryBroadcast($event))->delay(now()->addSeconds(5));\n        return;\n    }\n    throw $e;\n}","preventionTips":["Use a dedicated Redis instance or DB number for broadcasting to isolate failures from cache.","Configure Redis Cluster correctly in config/database.php when using clustered Redis.","Set read/connect timeouts on the Redis client to fail fast instead of hanging the broadcast.","Add Redis health checks to uptime monitoring and load balancer checks."],"tags":["broadcasting","redis","network","configuration"],"backgroundTag":null,"analyzedSha":"e0f6eb3518ac29fbbca8529e97d0df7fc9f24481","analyzedAt":"2026-08-11T20:52:37.562Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}