redis-config/README.md
This directory contains comprehensive Redis configuration files and scripts for LibreChat development and testing, supporting both cluster and single-node setups with optional TLS encryption.
All configurations are designed for local development and testing.
Redis must be installed on your system:
# macOS
brew install redis
# Ubuntu/Debian
sudo apt-get install redis-server
# CentOS/RHEL
sudo yum install redis
Redis CLI should be available (usually included with Redis)
# Navigate to the redis-config directory
cd redis-config
# Start and initialize the cluster
./start-cluster.sh
# Start Redis with TLS encryption on port 6380
./start-redis-tls.sh
# Use system Redis on default port 6379
redis-server
# Connect to the cluster
redis-cli -c -p 7001
# Test basic operations
SET test_key "Hello World"
GET test_key
# Test with CA certificate validation
redis-cli --tls --cacert certs/ca-cert.pem -p 6380 ping
# Connect to default Redis
redis-cli ping
./stop-cluster.sh
# Find and stop TLS Redis process
ps aux | grep "redis-server.*6380"
kill <PID>
redis-7001.conf - Configuration for node 1 (port 7001)redis-7002.conf - Configuration for node 2 (port 7002)redis-7003.conf - Configuration for node 3 (port 7003)start-cluster.sh - Starts and initializes the Redis clusterstop-cluster.sh - Stops all Redis nodes and cleans upstart-redis-tls.sh - Starts Redis with TLS encryption and CA certificate validationredis-tls.conf - TLS Redis configuration fileredis-config/
├── README.md
├── redis-7001.conf # Cluster node 1 configuration
├── redis-7002.conf # Cluster node 2 configuration
├── redis-7003.conf # Cluster node 3 configuration
├── redis-tls.conf # TLS Redis configuration
├── start-cluster.sh # Start cluster script
├── stop-cluster.sh # Stop cluster script
├── start-redis-tls.sh # Start TLS Redis script
├── certs/ # TLS certificates (created automatically)
│ ├── ca-cert.pem # Certificate Authority certificate
│ ├── ca-key.pem # CA private key
│ ├── server-cert.pem # Server certificate with SAN
│ ├── server-key.pem # Server private key
│ ├── redis.dh # Diffie-Hellman parameters
│ └── server.conf # OpenSSL certificate configuration
├── data/ # Data files (created automatically)
│ ├── 7001/ # Cluster node 1 data
│ ├── 7002/ # Cluster node 2 data
│ └── 7003/ # Cluster node 3 data
└── logs/ # Log directory (created automatically)
# Note: By default, Redis logs to stdout/stderr
# Log files would be created here if enabled in config
Update your .env file based on your chosen Redis configuration:
USE_REDIS=true
REDIS_URI=redis://127.0.0.1:7001,redis://127.0.0.1:7002,redis://127.0.0.1:7003
USE_REDIS=true
REDIS_URI=rediss://127.0.0.1:6380
REDIS_CA=/path/to/LibreChat/redis-config/certs/ca-cert.pem
USE_REDIS=true
REDIS_URI=redis://127.0.0.1:6379
# Use environment variable for dynamic key prefixing
REDIS_KEY_PREFIX_VAR=K_REVISION
# Or set static prefix
REDIS_KEY_PREFIX=librechat
# Connection limits
REDIS_MAX_LISTENERS=40
# Ping interval to keep connection alive (seconds, 0 to disable)
REDIS_PING_INTERVAL=0
# Reconnection configuration
REDIS_RETRY_MAX_DELAY=3000 # Max delay between reconnection attempts (ms)
REDIS_RETRY_MAX_ATTEMPTS=10 # Max reconnection attempts (0 = infinite)
REDIS_CONNECT_TIMEOUT=10000 # Connection timeout (ms)
REDIS_ENABLE_OFFLINE_QUEUE=true # Queue commands when disconnected
For secure Redis connections using TLS encryption with CA certificate validation:
# Start Redis with TLS on port 6380
./start-redis-tls.sh
Update your .env file:
# .env file - TLS Redis with CA certificate validation
USE_REDIS=true
REDIS_URI=rediss://127.0.0.1:6380
REDIS_CA=/path/to/LibreChat/redis-config/certs/ca-cert.pem
# Test Redis TLS connection with CA certificate
redis-cli --tls --cacert certs/ca-cert.pem -p 6380 ping
# Should return: PONG
# Test basic operations
redis-cli --tls --cacert certs/ca-cert.pem -p 6380 set test_tls "TLS Working"
redis-cli --tls --cacert certs/ca-cert.pem -p 6380 get test_tls
# Start LibreChat backend
npm run backend
# Look for these success indicators in logs:
# ✅ "No changes needed for 'USER' role permissions"
# ✅ "No changes needed for 'ADMIN' role permissions"
# ✅ "Server listening at http://localhost:3080"
# ✅ No "IoRedis connection error" messages
The TLS setup includes:
DNS: localhostIP: 127.0.0.1# If you see "Hostname/IP does not match certificate's altnames"
# Check certificate SAN entries:
openssl x509 -in certs/server-cert.pem -text -noout | grep -A3 "Subject Alternative Name"
# Should show: DNS:localhost, IP Address:127.0.0.1
# Check if Redis TLS is running
lsof -i :6380
# Check Redis TLS server logs
ps aux | grep redis-server
# Verify CA certificate path in .env
ls -la /path/to/LibreChat/redis-config/certs/ca-cert.pem
# Test LibreChat Redis configuration
cd /path/to/LibreChat
npm run backend
# Look for Redis connection errors in output
# Cluster information
redis-cli -p 7001 cluster info
# Node information
redis-cli -p 7001 cluster nodes
# Check specific node
redis-cli -p 7002 info replication
# Monitor all operations
redis-cli -p 7001 monitor
# Check memory usage
redis-cli -p 7001 info memory
redis-cli -p 7002 info memory
redis-cli -p 7003 info memory
redis-server --versionnetstat -tlnp | grep :700ps aux | grep redis-serverredis-cli -p 7001 ping./start-cluster.shredis-cli -p 7001 cluster nodesredis-cli -p 7001 CLUSTER RESETredis-cli -p 7001 info memoryredis-cli -p 7001 slowlog get 10maxmemory settings in configuration filesEach node is configured with:
With 3 nodes and no replicas:
The basic Redis cluster setup is designed for local development only.
The TLS Redis configuration provides:
For production use, consider:
requirepass or AUTH commands)tls-auth-clients yes)# Backup all nodes
mkdir -p backup
redis-cli -p 7001 BGSAVE
redis-cli -p 7002 BGSAVE
redis-cli -p 7003 BGSAVE
# Copy backup files
cp data/7001/dump.rdb backup/dump-7001.rdb
cp data/7002/dump.rdb backup/dump-7002.rdb
cp data/7003/dump.rdb backup/dump-7003.rdb
# Stop cluster
./stop-cluster.sh
# Restore backup files
cp backup/dump-7001.rdb data/7001/dump.rdb
cp backup/dump-7002.rdb data/7002/dump.rdb
cp backup/dump-7003.rdb data/7003/dump.rdb
# Start cluster
./start-cluster.sh
For Redis-specific issues:
For LibreChat integration: