Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

🔧 feat: Alternative DNS Lookup for AWS ElastiCache TLS Connections (#9264)

MarcAmickea3b6711827c
diff --git a/.env.example b/.env.example
index 4bbc86b2fa..2b11dc359a 100644
--- a/.env.example
+++ b/.env.example
@@ -660,6 +660,10 @@ HELP_AND_FAQ_URL=https://librechat.ai
# REDIS_URI=rediss://127.0.0.1:6380
# REDIS_CA=/path/to/ca-cert.pem
+# Elasticache may need to use an alternate dnsLookup for TLS connections. see "Special Note: Aws Elasticache Clusters with TLS" on this webpage: https://www.npmjs.com/package/ioredis
+# Enable alternative dnsLookup for redis
+# REDIS_USE_ALTERNATIVE_DNS_LOOKUP=true
+
# Redis authentication (if required)
# REDIS_USERNAME=your_redis_username
# REDIS_PASSWORD=your_redis_password
diff --git a/api/cache/cacheConfig.js b/api/cache/cacheConfig.js
index 79cba9fc54..613cfec74b 100644
--- a/api/cache/cacheConfig.js
+++ b/api/cache/cacheConfig.js
@@ -52,6 +52,9 @@ const cacheConfig = {
REDIS_CONNECT_TIMEOUT: math(process.env.REDIS_CONNECT_TIMEOUT, 10000),
/** Queue commands when disconnected */
REDIS_ENABLE_OFFLINE_QUEUE: isEnabled(process.env.REDIS_ENABLE_OFFLINE_QUEUE ?? 'true'),
+ /** flag to modify redis connection by adding dnsLookup this is required when connecting to elasticache for ioredis
+ * see "Special Note: Aws Elasticache Clusters with TLS" on this webpage: https://www.npmjs.com/package/ioredis **/
+ REDIS_USE_ALTERNATIVE_DNS_LOOKUP: isEnabled(process.env.REDIS_USE_ALTERNATIVE_DNS_LOOKUP),
/** Enable redis cluster without the need of multiple URIs */
USE_REDIS_CLUSTER: isEnabled(process.env.USE_REDIS_CLUSTER ?? 'false'),
CI: isEnabled(process.env.CI),
diff --git a/api/cache/redisClients.js b/api/cache/redisClients.js
index 83af0c38e3..ab59656add 100644
--- a/api/cache/redisClients.js
+++ b/api/cache/redisClients.js
@@ -53,6 +53,9 @@ if (cacheConfig.USE_REDIS) {
: new IoRedis.Cluster(
urls.map((url) => ({ host: url.hostname, port: parseInt(url.port, 10) || 6379 })),
{
+ ...(cacheConfig.REDIS_USE_ALTERNATIVE_DNS_LOOKUP
+ ? { dnsLookup: (address, callback) => callback(null, address) }
+ : {}),
redisOptions,
clusterRetryStrategy: (times) => {
if (