{"record":{"id":"837e0dc41a6879f7","repo":"BerriAI/litellm","slug":"error-updating-cache-settings-e","errorCode":null,"errorMessage":"Error updating cache settings: {e}","messagePattern":"Error updating cache settings: (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"litellm/proxy/management_endpoints/cache_settings_endpoints.py","lineNumber":673,"sourceCode":"        # control where LLM responses are cached.  An admin (or compromised\n        # admin) flipping the cache backend silently is a data-routing\n        # pivot; emit an audit-log row so the action is traceable.\n        await _emit_cache_settings_audit_log(\n            action=action,\n            before_settings=before_settings,\n            after_settings=cache_settings,\n            user_api_key_dict=user_api_key_dict,\n            litellm_changed_by=litellm_changed_by,\n        )\n\n        return {\n            \"message\": \"Cache settings updated successfully\",\n            \"status\": \"success\",\n            \"settings\": _redact_credentials(cache_settings),\n        }\n    except Exception as e:\n        verbose_proxy_logger.error(\"Error updating cache settings: %s\", e)\n        raise HTTPException(status_code=500, detail=f\"Error updating cache settings: {e}\")\n","sourceCodeStart":655,"sourceCodeEnd":674,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/management_endpoints/cache_settings_endpoints.py#L655-L674","documentation":"POST /cache/settings wraps encryption, the LiteLLM_CacheConfig upsert, audit logging, and cache reinitialization in one try/except. Any failure in that chain is logged as 'Error updating cache settings: <e>' and returned as HTTP 500 with the underlying exception text. Common real causes include invalid Redis credentials/hosts supplied in the settings payload, encryption failures when saving sensitive fields (e.g. no master key configured for encrypting secrets), and DB write errors.","triggerScenarios":"POST /cache/settings with a Redis URL/password that cannot be reached or authenticated; saving passwords when the deployment lacks the required encryption setup; a DB constraint/connection failure during the LiteLLM_CacheConfig upsert; invalid field values rejected during reinitialization.","commonSituations":"Typo'd Redis host or port in the Admin UI cache form; rotating Redis credentials but saving the old password; DB failover mid-update; versions where the settings row schema changed and the upsert conflicts.","solutions":["Check the proxy log line 'Error updating cache settings: <e>' — it names the exact failing step","If it names Redis: validate credentials separately with POST /cache/settings/test before saving, fix host/port/password/TLS settings","If it names encryption/DB: verify DATABASE_URL connectivity and the encryption setup for secrets, then retry","If the stored row is corrupted, clear LiteLLM_CacheConfig id='cache_config' and re-save fresh settings"],"exampleFix":"# before: untested credentials go straight to save\ncurl -X POST http://localhost:4000/cache/settings -d '{\"redis_url\": \"redis://wrong:6379\", ...}'\n\n# after: test first, then save\ncurl -X POST http://localhost:4000/cache/settings/test -d '{\"redis_url\": \"redis://right:6379\", ...}'  # 200\ncurl -X POST http://localhost:4000/cache/settings -d '{\"redis_url\": \"redis://right:6379\", ...}'  # 200","handlingStrategy":"retry","validationCode":"import httpx\n\n# Validate Redis credentials with the dedicated test route BEFORE saving\nr = httpx.post(f\"{PROXY_URL}/cache/settings/test\", json={\n    \"redis_url\": settings[\"redis_url\"],\n}, headers=hdrs)\nassert r.status_code == 200 and r.json().get(\"status\") != \"error\", f\"cache test failed: {r.text}\"","typeGuard":null,"tryCatchPattern":"import httpx, time\n\ndef save_cache_settings(url, hdrs, payload, attempts=3):\n    for i in range(attempts):\n        r = httpx.post(f\"{url}/cache/settings\", json=payload, headers=hdrs, timeout=30)\n        if r.status_code == 200:\n            return r.json()\n        if r.status_code == 500 and \"Error updating cache settings\" in r.text:\n            cause = r.text  # contains underlying exception; only retry if transient (e.g. conn drop)\n            time.sleep(2 ** i)\n            continue\n        r.raise_for_status()\n    raise RuntimeError(f\"cache settings update failed repeatedly: {cause}\")","preventionTips":["Always run POST /cache/settings/test before POST /cache/settings","Keep Redis credentials in a secret manager and rotate both together","Check 'Error updating cache settings' server log line before blind retries"],"tags":["litellm-proxy","cache","redis","internal-error","settings"],"backgroundTag":"internal-server-error","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}