Note to first-time contributors: Please open a discussion post in Discussions and describe your changes before submitting a pull request.
Before submitting, make sure you've checked the following:
Target branch: Please verify that the pull request targets the dev branch.
Description: Provide a concise description of the changes made in this pull request.
Changelog: Ensure a changelog entry following the format of Keep a Changelog is added at the bottom of the PR description.
Documentation: Have you updated relevant documentation Open WebUI Docs, or other documentation sources?
Dependencies: Are there any new dependencies? Have you updated the dependency versions in the documentation?
Testing: Have you written and run sufficient tests to validate the changes?
Code review: Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards?
Prefix: To clearly categorize this pull request, prefix the pull request title using one of the following:
BREAKING CHANGE: Significant changes that may affect compatibility
build: Changes that affect the build system or external dependencies
ci: Changes to our continuous integration processes or workflows
chore: Refactor, cleanup, or other non-functional code changes
docs: Documentation update or addition
feat: Introduces a new feature or enhancement to the codebase
fix: Bug fix or error correction
i18n: Internationalization or localization changes
perf: Performance improvement
refactor: Code restructuring for better maintainability, readability, or scalability
style: Changes that do not affect the meaning of the code (white space, formatting, missing semi-colons, etc.)
test: Adding missing tests or correcting existing tests
WIP: Work in progress, a temporary label for incomplete or ongoing work
Changelog Entry
Description
Introduced two new boolean environment variables, REDIS_CLUSTER_MODE and WEBSOCKET_REDIS_CLUSTER_MODE (True or False), that trigger the use of redis.cluster.RedisCluster and redis.asyncio.cluster.RedisCluster client classes from the redis-py package in order to properly support connections to Redis in cluster mode.
Setting these new environment variables will require also setting REDIS_URL and/or WEBSOCKET_REDIS_URL, and they have lower precedence than REDIS_SENTINEL_HOSTS and WEBSOCKET_SENTINEL_HOSTS variables if the latter are also defined, i.e., they have no effect if connecting to sentinel hosts.
Added
boolean environment variables: REDIS_CLUSTER_MODE and WEBSOCKET_REDIS_CLUSTER_MODE
Changed
Select the appropriate redis-py client classes based on desired mode: single instance, sentinel hosts, or cluster mode
Deprecated
None
Removed
None
Fixed
#16157: Backend cannot connect to Redis in cluster mode
Security
None
Breaking Changes
None
Additional Information
I need help to write unit tests for using the new Redis clients as I'm not familiar with mocking using pytest.
Corresponding documentation changes for the new environment variables submitted in open-webui/docs PR #638.
Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
## 📋 Pull Request Information
**Original PR:** https://github.com/open-webui/open-webui/pull/16160
**Author:** [@erhhung](https://github.com/erhhung)
**Created:** 7/30/2025
**Status:** ❌ Closed
**Base:** `dev` ← **Head:** `redis-cluster`
---
### 📝 Commits (3)
- [`b2715a4`](https://github.com/open-webui/open-webui/commit/b2715a45e84b2f81bf7cd51eb79635cbbecf7bd8) enh: support for Redis in cluster mode
- [`3c60b8a`](https://github.com/open-webui/open-webui/commit/3c60b8a8a089b848d747a602aab1b3772d6d67e7) Merge branch 'dev' into redis-cluster
- [`9ba668b`](https://github.com/open-webui/open-webui/commit/9ba668b9b7144e6e996dca10b82ff5a48d7b34f9) Merge branch 'dev' into redis-cluster
### 📊 Changes
**7 files changed** (+39 additions, -23 deletions)
<details>
<summary>View changed files</summary>
📝 `Dockerfile` (+1 -0)
📝 `backend/open_webui/config.py` (+6 -4)
📝 `backend/open_webui/env.py` (+6 -9)
📝 `backend/open_webui/main.py` (+4 -1)
📝 `backend/open_webui/socket/main.py` (+7 -1)
📝 `backend/open_webui/socket/utils.py` (+4 -4)
📝 `backend/open_webui/utils/redis.py` (+11 -4)
</details>
### 📄 Description
# Pull Request Checklist
### Note to first-time contributors: Please open a discussion post in [Discussions](https://github.com/open-webui/open-webui/discussions) and describe your changes before submitting a pull request.
**Before submitting, make sure you've checked the following:**
- [X] **Target branch:** Please verify that the pull request targets the `dev` branch.
- [X] **Description:** Provide a concise description of the changes made in this pull request.
- [X] **Changelog:** Ensure a changelog entry following the format of [Keep a Changelog](https://keepachangelog.com/) is added at the bottom of the PR description.
- [X] **Documentation:** Have you updated relevant documentation [Open WebUI Docs](https://github.com/open-webui/docs), or other documentation sources?
- [X] **Dependencies:** Are there any new dependencies? Have you updated the dependency versions in the documentation?
- [ ] **Testing:** Have you written and run sufficient tests to validate the changes?
- [X] **Code review:** Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards?
- [X] **Prefix:** To clearly categorize this pull request, prefix the pull request title using one of the following:
- **BREAKING CHANGE**: Significant changes that may affect compatibility
- **build**: Changes that affect the build system or external dependencies
- **ci**: Changes to our continuous integration processes or workflows
- **chore**: Refactor, cleanup, or other non-functional code changes
- **docs**: Documentation update or addition
- **feat**: Introduces a new feature or enhancement to the codebase
- **fix**: Bug fix or error correction
- **i18n**: Internationalization or localization changes
- **perf**: Performance improvement
- **refactor**: Code restructuring for better maintainability, readability, or scalability
- **style**: Changes that do not affect the meaning of the code (white space, formatting, missing semi-colons, etc.)
- **test**: Adding missing tests or correcting existing tests
- **WIP**: Work in progress, a temporary label for incomplete or ongoing work
# Changelog Entry
### Description
Introduced two new _boolean_ environment variables, `REDIS_CLUSTER_MODE` and `WEBSOCKET_REDIS_CLUSTER_MODE` (`True` or `False`), that trigger the use of [`redis.cluster.RedisCluster`](https://redis.readthedocs.io/en/stable/connections.html#cluster-client) and [`redis.asyncio.cluster.RedisCluster`](https://redis.readthedocs.io/en/stable/connections.html#async-cluster-client) client classes from the [`redis-py`](https://pypi.org/project/redis/) package in order to **properly** support connections to Redis in cluster mode.
Setting these new environment variables will require also setting `REDIS_URL` and/or `WEBSOCKET_REDIS_URL`, and they have **lower precedence** than `REDIS_SENTINEL_HOSTS` and `WEBSOCKET_SENTINEL_HOSTS` variables if the latter are also defined, i.e., they have no effect if connecting to sentinel hosts.
### Added
- _boolean_ environment variables: `REDIS_CLUSTER_MODE` and `WEBSOCKET_REDIS_CLUSTER_MODE`
### Changed
- Select the appropriate `redis-py` client classes based on desired mode: single instance, sentinel hosts, or cluster mode
### Deprecated
_None_
### Removed
_None_
### Fixed
#16157: Backend cannot connect to Redis in cluster mode
### Security
_None_
### Breaking Changes
_None_
---
### Additional Information
I **need help** to write unit tests for using the new Redis clients as I'm not familiar with mocking using `pytest`.
Corresponding **documentation** changes for the new environment variables submitted in [`open-webui/docs` PR #638](https://github.com/open-webui/docs/pull/638).
### Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms.
---
<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/16160
Author: @erhhung
Created: 7/30/2025
Status: ❌ Closed
Base:
dev← Head:redis-cluster📝 Commits (3)
b2715a4enh: support for Redis in cluster mode3c60b8aMerge branch 'dev' into redis-cluster9ba668bMerge branch 'dev' into redis-cluster📊 Changes
7 files changed (+39 additions, -23 deletions)
View changed files
📝
Dockerfile(+1 -0)📝
backend/open_webui/config.py(+6 -4)📝
backend/open_webui/env.py(+6 -9)📝
backend/open_webui/main.py(+4 -1)📝
backend/open_webui/socket/main.py(+7 -1)📝
backend/open_webui/socket/utils.py(+4 -4)📝
backend/open_webui/utils/redis.py(+11 -4)📄 Description
Pull Request Checklist
Note to first-time contributors: Please open a discussion post in Discussions and describe your changes before submitting a pull request.
Before submitting, make sure you've checked the following:
devbranch.Changelog Entry
Description
Introduced two new boolean environment variables,
REDIS_CLUSTER_MODEandWEBSOCKET_REDIS_CLUSTER_MODE(TrueorFalse), that trigger the use ofredis.cluster.RedisClusterandredis.asyncio.cluster.RedisClusterclient classes from theredis-pypackage in order to properly support connections to Redis in cluster mode.Setting these new environment variables will require also setting
REDIS_URLand/orWEBSOCKET_REDIS_URL, and they have lower precedence thanREDIS_SENTINEL_HOSTSandWEBSOCKET_SENTINEL_HOSTSvariables if the latter are also defined, i.e., they have no effect if connecting to sentinel hosts.Added
REDIS_CLUSTER_MODEandWEBSOCKET_REDIS_CLUSTER_MODEChanged
redis-pyclient classes based on desired mode: single instance, sentinel hosts, or cluster modeDeprecated
None
Removed
None
Fixed
#16157: Backend cannot connect to Redis in cluster mode
Security
None
Breaking Changes
None
Additional Information
I need help to write unit tests for using the new Redis clients as I'm not familiar with mocking using
pytest.Corresponding documentation changes for the new environment variables submitted in
open-webui/docsPR #638.Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.