From 7552b01b3fa46b7493b0559db412cdbc67dffd12 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Tue, 29 Sep 2026 22:31:42 +0200 Subject: [PATCH] fix: chats fail with a 500 error right after Redis restarts After Redis restarted or closed Open WebUI's connections, the first few requests that needed Redis failed. Chat requests answered with a 500 error, and a browser tab connecting at that moment got no live updates, such as streamed replies, until it was reloaded. Open WebUI now reconnects and retries the failed Redis call once when Redis has closed the connection, so requests go through as soon as Redis is back. While Redis is down, requests still fail as before. --- backend/open_webui/utils/redis.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/open_webui/utils/redis.py b/backend/open_webui/utils/redis.py index 0eb1469862..b80577c6bd 100644 --- a/backend/open_webui/utils/redis.py +++ b/backend/open_webui/utils/redis.py @@ -334,7 +334,9 @@ def get_redis_connection( ) elif redis_url: factory = getattr(redis_mod, 'from_url', None) or redis_mod.Redis.from_url - connection = factory(redis_url, decode_responses=decode_responses, **extra) + # reconnect once when Redis has closed a pooled connection, e.g. after a restart + retry = redis_mod.retry.Retry(_redis_sync.backoff.NoBackoff(), 1, supported_errors=(redis_mod.ConnectionError,)) + connection = factory(redis_url, decode_responses=decode_responses, retry=retry, **extra) _CONNECTION_POOL[cache_key] = connection return connection