# Using your own Redis server

**Version requirements**: We support any version _starting from 6.2_. Redis Cluster and Redis Sentinel are not supported.

Generally, there is no reason to do this as Sourcegraph only stores ephemeral cache and session data in Redis. However, if you want to use an external Redis server with Sourcegraph, you can follow the deployment specific guidance below.

Sourcegraph uses two Redis instances, configured with these environment variables:

-   `REDIS_CACHE_ENDPOINT` for cached data. Set `maxmemory-policy allkeys-lru` on this instance; the frontend logs a warning on startup if it is not set.
-   `REDIS_STORE_ENDPOINT` for persistent data, such as user sessions and locks. Set `maxmemory-policy noeviction` on this instance.

Each value is either `host:port`, or a URL following the [IANA specification for Redis URLs](https://www.iana.org/assignments/uri-schemes/prov/redis), such as `redis://:mypassword@redis-store.example.com:6379/0`. Use the `rediss://` scheme for a TLS connection.

## Docker Compose

Set both environment variables on every service that connects to Redis:

-   `sourcegraph-frontend-0`
-   `sourcegraph-frontend-internal`
-   `gitserver-0`
-   `searcher-0`
-   `worker`
-   `precise-code-intel-worker`
-   `syntactic-code-intel-worker`

A service without them keeps connecting to the built-in `redis-cache` and `redis-store` containers.

1. Copy the [external Redis example](https://github.com/sourcegraph/deploy-sourcegraph-docker/blob/main/docker-compose/examples/external-redis/docker-compose.override.yaml) into your `docker-compose.override.yaml`. It sets the variables on these services and disables the built-in Redis containers.
2. Replace the example values of `REDIS_CACHE_ENDPOINT` and `REDIS_STORE_ENDPOINT` with your Redis endpoints.
3. Apply the change with `docker compose up -d --remove-orphans`.

## Kubernetes

### Kubernetes without Helm

-   See our documentation for Kubernetes [here](/self-hosted/deploy/kubernetes/configure#external-redis)
-   **Related:** [How to Set a Password for Redis using a ConfigMap](/self-hosted/how-to/redis-configmap)
