{"record":{"id":"7d3360bf2165768c","repo":"BerriAI/litellm","slug":"503","errorCode":"503","errorMessage":"Cache not initialized. litellm.cache is None","messagePattern":"Cache not initialized\\. litellm\\.cache is None","errorType":"http","errorClass":"ProxyException","httpStatus":503,"severity":"warning","filePath":"litellm/proxy/caching_routes.py","lineNumber":62,"sourceCode":"        return masker.mask_dict(cleaned_params)\n    except (AttributeError, TypeError) as e:\n        verbose_proxy_logger.debug(\"Error extracting cache params: %s\", e)\n        return {}\n\n\n@router.get(\n    \"/ping\",\n    response_model=CachePingResponse,\n    dependencies=[Depends(user_api_key_auth)],\n)\nasync def cache_ping():\n    \"\"\"\n    Endpoint for checking if cache can be pinged\n    \"\"\"\n    litellm_cache_params: dict[str, Any] = {}\n    cleaned_cache_params: dict[str, Any] = {}\n    if litellm.cache is None:\n        raise ProxyException(\n            message=safe_dumps(\n                {\n                    \"message\": \"Cache not initialized. litellm.cache is None\",\n                    \"litellm_cache_params\": \"{}\",\n                    \"health_check_cache_params\": \"{}\",\n                }\n            ),\n            type=ProxyErrorTypes.cache_ping_error,\n            param=\"cache_ping\",\n            code=503,\n        )\n    try:\n        litellm_cache_params = masker.mask_dict(vars(litellm.cache))\n        # remove field that might reference itself\n        litellm_cache_params.pop(\"cache\", None)\n        cleaned_cache_params = _extract_cache_params()\n\n        if litellm.cache.type == \"redis\":","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/caching_routes.py#L44-L80","documentation":"GET /cache/ping checks LiteLLM's cache subsystem before pinging anything: if the global litellm.cache is None (the proxy config has no cache_settings, so no cache object was constructed at startup) it raises a ProxyException with HTTP 503 whose JSON body says 'Cache not initialized. litellm.cache is None' plus empty cache params. It signals missing configuration, not a broken Redis connection.","triggerScenarios":"GET /cache/ping (with any valid virtual key) against a proxy whose config.yaml has no litellm_settings.cache_settings block.","commonSituations":"Cache health checks run against a proxy deployed without caching; Redis env vars (REDIS_HOST etc.) set but cache_settings never added to config; monitoring wired up before the cache feature itself.","solutions":["Add litellm_settings.cache_settings (type: redis plus host/port/password or url) to config.yaml and restart the proxy.","Confirm GET /cache/ping returns 200 with latency after restart.","If caching is genuinely unused, drop /cache/ping from monitoring to remove the noise."],"exampleFix":"# before - config.yaml has no cache settings (litellm.cache stays None)\n# after\nlitellm_settings:\n  cache_settings:\n    type: redis\n    host: redis.example.com\n    port: 6379\n    password: os.environ/REDIS_PASSWORD","handlingStrategy":"validation","validationCode":"import httpx\n\ndef assert_cache_configured(base_url: str, api_key: str) -> None:\n    r = httpx.get(f'{base_url}/cache/ping', headers={'Authorization': f'Bearer {api_key}'})\n    if r.status_code == 503 and 'Cache not initialized' in r.text:\n        raise RuntimeError('proxy has no cache configured - add litellm_settings.cache_settings')","typeGuard":"def has_cache_settings(proxy_config: dict) -> bool:\n    return bool((proxy_config.get('litellm_settings') or {}).get('cache_settings'))","tryCatchPattern":"r = httpx.get(f'{base}/cache/ping', headers=auth)\nif r.status_code == 503 and 'Cache not initialized' in r.text:\n    # configuration gap, not an outage - file a config fix instead of paging on-call\n    mark_cache_unconfigured(env)","preventionTips":["Declare cache_settings in config.yaml whenever /cache/* endpoints are monitored.","Add a deploy-time check that /cache/ping returns 200 when caching is expected.","Remember env vars alone (REDIS_HOST) do not configure the proxy cache."],"tags":["litellm-proxy","cache","redis","configuration","health-check","http-503"],"backgroundTag":"cache-not-configured","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","schemaVersion":2},"datasetVersion":"2026-08-21T08:17:14.275Z"}