{"record":{"id":"bf1e97e20f99dff0","repo":"BerriAI/litellm","slug":"either-redis-url-or-both-redis-host-and-redis","errorCode":null,"errorMessage":"Either 'REDIS_URL' or both 'REDIS_HOST' and 'REDIS_PORT' must be specified for Redis.","messagePattern":"Either 'REDIS_URL' or both 'REDIS_HOST' and 'REDIS_PORT' must be specified for Redis\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/_redis.py","lineNumber":329,"sourceCode":"            auth_response = self.read_response()\n\n        if str_if_bytes(auth_response) != \"OK\":\n            raise AuthenticationError(\"Azure AD authentication failed for Redis\")\n\n    # Attach the live credential object so async paths can wrap it in\n    # AzureADCredentialProvider for refresh-aware token retrieval. The raw\n    # client_id/tenant_id/secret are intentionally NOT exposed here — the\n    # credential closure already holds them.\n    ad_connect._azure_credential = credential\n    return ad_connect\n\n\ndef get_redis_url_from_environment():\n    if \"REDIS_URL\" in os.environ:\n        return os.environ[\"REDIS_URL\"]\n\n    if \"REDIS_HOST\" not in os.environ or \"REDIS_PORT\" not in os.environ:\n        raise ValueError(\"Either 'REDIS_URL' or both 'REDIS_HOST' and 'REDIS_PORT' must be specified for Redis.\")\n\n    if \"REDIS_SSL\" in os.environ and os.environ[\"REDIS_SSL\"].lower() == \"true\":\n        redis_protocol = \"rediss\"\n    else:\n        redis_protocol = \"redis\"\n\n    # Build authentication part of URL\n    auth_part = \"\"\n    if \"REDIS_USERNAME\" in os.environ and \"REDIS_PASSWORD\" in os.environ:\n        auth_part = f\"{os.environ['REDIS_USERNAME']}:{os.environ['REDIS_PASSWORD']}@\"\n    elif \"REDIS_PASSWORD\" in os.environ:\n        auth_part = f\"{os.environ['REDIS_PASSWORD']}@\"\n\n    return f\"{redis_protocol}://{auth_part}{os.environ['REDIS_HOST']}:{os.environ['REDIS_PORT']}\"\n\n\ndef _get_redis_client_logic(**env_overrides):\n    \"\"\"","sourceCodeStart":311,"sourceCodeEnd":347,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/_redis.py#L311-L347","documentation":"Error \"Either 'REDIS_URL' or both 'REDIS_HOST' and 'REDIS_PORT' must be specified for Redis.\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/_redis.py:329 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set REDIS_URL, or set both REDIS_HOST and REDIS_PORT environment variables."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}