Skip to content

[Bug]: router cache MOVED Error with Redis Cluster #8878

@subnet-dev

Description

@subnet-dev

What happened?

Configuration Used:

Documentation: https://docs.litellm.ai/docs/proxy/caching#redis-cluster

litellm_settings:
  cache: True
  cache_params:
    type: redis
    namespace: "litellm.caching.caching"
    redis_startup_nodes:
      - host: os.environ/REDIS_HOST
        port: os.environ/REDIS_PORT
router_settings:
  routing_strategy: usage-based-routing-v2
  redis_host: os.environ/REDIS_HOST
  redis_port: os.environ/REDIS_PORT
  redis_password: os.environ/REDIS_PASSWORD
  timeout: 600
  num_retries: 2

Expected Behavior:

Redis caching should function without triggering MOVED errors, and cache increments should not fail.

Steps to Reproduce:

  1. Configure LiteLLM with Redis cluster caching (see the configuration above).
  2. Run requests that trigger cache incrementation.
  3. Check the logs for MOVED errors.

Environment:

  • LiteLLM Version: 1.61.19
  • Redis Version: 7.4.2
  • Redis Configuration: Clustered (redis-cluster bitnami helm chart)

Would it be possible to improve Redis error handling to prevent these failures?

Relevant log output

22:24:17 - LiteLLM Router:INFO: router.py:1019 - litellm.acompletion(model=hosted_vllm/mistralai/Mistral-Small-24B-Instruct-2501) 200 OK
INFO:     172.16.6.127:61733 - "POST /v1/chat/completions HTTP/1.1" 200 OK
22:24:17 - LiteLLM:ERROR: redis_cache.py:584 - LiteLLM Redis Caching: async async_increment() - Got exception from REDIS MOVED 8116 172.16.7.254:6379, Writing value=1
22:24:17 - LiteLLM Router:ERROR: router.py:3546 - litellm.router.Router::deployment_callback_on_success(): Exception occured - MOVED 8116 172.16.7.254:6379
Traceback (most recent call last):
  File "/usr/lib/python3.13/site-packages/litellm/router.py", line 3531, in deployment_callback_on_success
    await self.cache.async_increment_cache(
    ...<4 lines>...
    )
  File "/usr/lib/python3.13/site-packages/litellm/caching/dual_cache.py", line 374, in async_increment_cache
    raise e  # don't log if exception is raised
    ^^^^^^^
  File "/usr/lib/python3.13/site-packages/litellm/caching/dual_cache.py", line 365, in async_increment_cache
    result = await self.redis_cache.async_increment(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<4 lines>...
    )
    ^
  File "/usr/lib/python3.13/site-packages/litellm/caching/redis_cache.py", line 589, in async_increment
    raise e
  File "/usr/lib/python3.13/site-packages/litellm/caching/redis_cache.py", line 547, in async_increment
    result = await _redis_client.incrbyfloat(name=key, amount=value)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/redis/asyncio/client.py", line 550, in execute_command
    return await conn.retry.call_with_retry(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<4 lines>...
    )
    ^
  File "/usr/lib/python3.13/site-packages/redis/asyncio/retry.py", line 59, in call_with_retry
    return await do()
           ^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/redis/asyncio/client.py", line 524, in _send_command_parse_response
    return await self.parse_response(conn, command_name, **options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/redis/asyncio/client.py", line 571, in parse_response
    response = await connection.read_response()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/redis/asyncio/connection.py", line 537, in read_response
    raise response from None
redis.exceptions.ResponseError: MOVED 8116 172.16.7.254:6379
22:24:17 - LiteLLM:ERROR: redis_cache.py:584 - LiteLLM Redis Caching: async async_increment() - Got exception from REDIS MOVED 5948 172.16.7.254:6379, Writing value=301
22:24:17 - LiteLLM:ERROR: lowest_tpm_rpm_v2.py:311 - litellm.proxy.hooks.lowest_tpm_rpm_v2.py::async_log_success_event(): Exception occured - MOVED 5948 172.16.7.254:6379
Traceback (most recent call last):
  File "/usr/lib/python3.13/site-packages/litellm/router_strategy/lowest_tpm_rpm_v2.py", line 300, in async_log_success_event
    await self.router_cache.async_increment_cache(
    ...<4 lines>...
    )
  File "/usr/lib/python3.13/site-packages/litellm/caching/dual_cache.py", line 374, in async_increment_cache
    raise e  # don't log if exception is raised
    ^^^^^^^
  File "/usr/lib/python3.13/site-packages/litellm/caching/dual_cache.py", line 365, in async_increment_cache
    result = await self.redis_cache.async_increment(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<4 lines>...
    )
    ^
  File "/usr/lib/python3.13/site-packages/litellm/caching/redis_cache.py", line 589, in async_increment
    raise e
  File "/usr/lib/python3.13/site-packages/litellm/caching/redis_cache.py", line 547, in async_increment
    result = await _redis_client.incrbyfloat(name=key, amount=value)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/redis/asyncio/client.py", line 550, in execute_command
    return await conn.retry.call_with_retry(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<4 lines>...
    )
    ^
  File "/usr/lib/python3.13/site-packages/redis/asyncio/retry.py", line 59, in call_with_retry
    return await do()
           ^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/redis/asyncio/client.py", line 524, in _send_command_parse_response
    return await self.parse_response(conn, command_name, **options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/redis/asyncio/client.py", line 571, in parse_response
    response = await connection.read_response()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/redis/asyncio/connection.py", line 537, in read_response
    raise response from None
redis.exceptions.ResponseError: MOVED 5948 172.16.7.254:6379
22:24:18 - LiteLLM Router:INFO: router.py:1019 - litellm.acompletion(model=hosted_vllm/mistralai/Mistral-Small-24B-Instruct-2501) 200 OK
INFO:     172.16.6.127:61727 - "POST /v1/chat/completions HTTP/1.1" 200 OK
22:24:18 - LiteLLM:ERROR: redis_cache.py:584 - LiteLLM Redis Caching: async async_increment() - Got exception from REDIS MOVED 8116 172.16.7.254:6379, Writing value=1
22:24:18 - LiteLLM Router:ERROR: router.py:3546 - litellm.router.Router::deployment_callback_on_success(): Exception occured - MOVED 8116 172.16.7.254:6379
Traceback (most recent call last):
  File "/usr/lib/python3.13/site-packages/litellm/router.py", line 3531, in deployment_callback_on_success
    await self.cache.async_increment_cache(
    ...<4 lines>...
    )
  File "/usr/lib/python3.13/site-packages/litellm/caching/dual_cache.py", line 374, in async_increment_cache
    raise e  # don't log if exception is raised
    ^^^^^^^
  File "/usr/lib/python3.13/site-packages/litellm/caching/dual_cache.py", line 365, in async_increment_cache
    result = await self.redis_cache.async_increment(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<4 lines>...
    )
    ^
  File "/usr/lib/python3.13/site-packages/litellm/caching/redis_cache.py", line 589, in async_increment
    raise e
  File "/usr/lib/python3.13/site-packages/litellm/caching/redis_cache.py", line 547, in async_increment
    result = await _redis_client.incrbyfloat(name=key, amount=value)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/redis/asyncio/client.py", line 550, in execute_command
    return await conn.retry.call_with_retry(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<4 lines>...
    )
    ^
  File "/usr/lib/python3.13/site-packages/redis/asyncio/retry.py", line 59, in call_with_retry
    return await do()
           ^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/redis/asyncio/client.py", line 524, in _send_command_parse_response
    return await self.parse_response(conn, command_name, **options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/redis/asyncio/client.py", line 571, in parse_response
    response = await connection.read_response()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/redis/asyncio/connection.py", line 537, in read_response
    raise response from None
redis.exceptions.ResponseError: MOVED 8116 172.16.7.254:6379
22:24:18 - LiteLLM:ERROR: redis_cache.py:584 - LiteLLM Redis Caching: async async_increment() - Got exception from REDIS MOVED 5948 172.16.7.254:6379, Writing value=326
22:24:18 - LiteLLM:ERROR: lowest_tpm_rpm_v2.py:311 - litellm.proxy.hooks.lowest_tpm_rpm_v2.py::async_log_success_event(): Exception occured - MOVED 5948 172.16.7.254:6379
Traceback (most recent call last):
  File "/usr/lib/python3.13/site-packages/litellm/router_strategy/lowest_tpm_rpm_v2.py", line 300, in async_log_success_event
    await self.router_cache.async_increment_cache(
    ...<4 lines>...
    )
  File "/usr/lib/python3.13/site-packages/litellm/caching/dual_cache.py", line 374, in async_increment_cache
    raise e  # don't log if exception is raised
    ^^^^^^^
  File "/usr/lib/python3.13/site-packages/litellm/caching/dual_cache.py", line 365, in async_increment_cache
    result = await self.redis_cache.async_increment(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<4 lines>...
    )
    ^
  File "/usr/lib/python3.13/site-packages/litellm/caching/redis_cache.py", line 589, in async_increment
    raise e
  File "/usr/lib/python3.13/site-packages/litellm/caching/redis_cache.py", line 547, in async_increment
    result = await _redis_client.incrbyfloat(name=key, amount=value)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/redis/asyncio/client.py", line 550, in execute_command
    return await conn.retry.call_with_retry(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<4 lines>...
    )
    ^
  File "/usr/lib/python3.13/site-packages/redis/asyncio/retry.py", line 59, in call_with_retry
    return await do()
           ^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/redis/asyncio/client.py", line 524, in _send_command_parse_response
    return await self.parse_response(conn, command_name, **options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/redis/asyncio/client.py", line 571, in parse_response
    response = await connection.read_response()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/redis/asyncio/connection.py", line 537, in read_response
    raise response from None
redis.exceptions.ResponseError: MOVED 5948 172.16.7.254:6379
22:24:18 - LiteLLM Router:INFO: router.py:1019 - litellm.acompletion(model=hosted_vllm/mistralai/Mistral-Small-24B-Instruct-2501) 200 OK
INFO:     172.16.6.127:61761 - "POST /v1/chat/completions HTTP/1.1" 200 OK
22:24:18 - LiteLLM:ERROR: redis_cache.py:584 - LiteLLM Redis Caching: async async_increment() - Got exception from REDIS MOVED 8116 172.16.7.254:6379, Writing value=1
22:24:18 - LiteLLM Router:ERROR: router.py:3546 - litellm.router.Router::deployment_callback_on_success(): Exception occured - MOVED 8116 172.16.7.254:6379
Traceback (most recent call last):
  File "/usr/lib/python3.13/site-packages/litellm/router.py", line 3531, in deployment_callback_on_success
    await self.cache.async_increment_cache(
    ...<4 lines>...
    )
  File "/usr/lib/python3.13/site-packages/litellm/caching/dual_cache.py", line 374, in async_increment_cache
    raise e  # don't log if exception is raised
    ^^^^^^^
  File "/usr/lib/python3.13/site-packages/litellm/caching/dual_cache.py", line 365, in async_increment_cache
    result = await self.redis_cache.async_increment(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<4 lines>...
    )
    ^
  File "/usr/lib/python3.13/site-packages/litellm/caching/redis_cache.py", line 589, in async_increment
    raise e
  File "/usr/lib/python3.13/site-packages/litellm/caching/redis_cache.py", line 547, in async_increment
    result = await _redis_client.incrbyfloat(name=key, amount=value)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/redis/asyncio/client.py", line 550, in execute_command
    return await conn.retry.call_with_retry(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<4 lines>...
    )
    ^
  File "/usr/lib/python3.13/site-packages/redis/asyncio/retry.py", line 59, in call_with_retry
    return await do()
           ^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/redis/asyncio/client.py", line 524, in _send_command_parse_response
    return await self.parse_response(conn, command_name, **options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/redis/asyncio/client.py", line 571, in parse_response
    response = await connection.read_response()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/redis/asyncio/connection.py", line 537, in read_response
    raise response from None
redis.exceptions.ResponseError: MOVED 8116 172.16.7.254:6379
22:24:18 - LiteLLM:ERROR: redis_cache.py:584 - LiteLLM Redis Caching: async async_increment() - Got exception from REDIS MOVED 5948 172.16.7.254:6379, Writing value=329
22:24:18 - LiteLLM:ERROR: lowest_tpm_rpm_v2.py:311 - litellm.proxy.hooks.lowest_tpm_rpm_v2.py::async_log_success_event(): Exception occured - MOVED 5948 172.16.7.254:6379
Traceback (most recent call last):
  File "/usr/lib/python3.13/site-packages/litellm/router_strategy/lowest_tpm_rpm_v2.py", line 300, in async_log_success_event
    await self.router_cache.async_increment_cache(
    ...<4 lines>...
    )
  File "/usr/lib/python3.13/site-packages/litellm/caching/dual_cache.py", line 374, in async_increment_cache
    raise e  # don't log if exception is raised
    ^^^^^^^
  File "/usr/lib/python3.13/site-packages/litellm/caching/dual_cache.py", line 365, in async_increment_cache
    result = await self.redis_cache.async_increment(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<4 lines>...
    )
    ^
  File "/usr/lib/python3.13/site-packages/litellm/caching/redis_cache.py", line 589, in async_increment
    raise e
  File "/usr/lib/python3.13/site-packages/litellm/caching/redis_cache.py", line 547, in async_increment
    result = await _redis_client.incrbyfloat(name=key, amount=value)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/redis/asyncio/client.py", line 550, in execute_command
    return await conn.retry.call_with_retry(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<4 lines>...
    )
    ^
  File "/usr/lib/python3.13/site-packages/redis/asyncio/retry.py", line 59, in call_with_retry
    return await do()
           ^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/redis/asyncio/client.py", line 524, in _send_command_parse_response
    return await self.parse_response(conn, command_name, **options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/redis/asyncio/client.py", line 571, in parse_response
    response = await connection.read_response()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/redis/asyncio/connection.py", line 537, in read_response
    raise response from None
redis.exceptions.ResponseError: MOVED 5948 172.16.7.254:6379

Are you a ML Ops Team?

No

What LiteLLM version are you on ?

v1.61.19

Twitter / LinkedIn details

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions