From 9668fae1a11b133ffaa91b6d2e7a88f7b0a6ec51 Mon Sep 17 00:00:00 2001 From: PRABHU KIRAN VANDRANKI <72809214+VANDRANKI@users.noreply.github.com> Date: Fri, 17 Apr 2026 11:52:54 -0400 Subject: [PATCH] fix: degrade gracefully when cache init fails instead of crashing proxy --- litellm/proxy/proxy_server.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index 2d789b982da..e1551ee7fec 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -3130,11 +3130,19 @@ class ProxyConfig: cache_params[key] = get_secret(value) ## to pass a complete url, or set ssl=True, etc. just set it as `os.environ[REDIS_URL] = `, _redis.py checks for REDIS specific environment variables - self._init_cache(cache_params=cache_params) - if litellm.cache is not None: - verbose_proxy_logger.debug( - f"{blue_color_code}Set Cache on LiteLLM Proxy{reset_color_code}" + try: + self._init_cache(cache_params=cache_params) + if litellm.cache is not None: + verbose_proxy_logger.debug( + f"{blue_color_code}Set Cache on LiteLLM Proxy{reset_color_code}" + ) + except Exception as e: + verbose_proxy_logger.warning( + f"Cache initialisation failed - proxy will start without caching. " + f"Error: {e}. " + "Fix your cache configuration and restart the proxy to enable caching." ) + litellm.cache = None elif key == "cache" and value is False: pass elif key == "guardrails":