diff --git a/Gemfile b/Gemfile
index 50287ffa77abd681722ce1d7cfafdec1c2d05ea9..f5bd290e37d02024b04504d730efff6ced73455b 100644
--- a/Gemfile
+++ b/Gemfile
@@ -11,7 +11,7 @@ gem 'mysql2', '~> 0.5.4'
 gem 'puma', '~> 5.6'
 gem 'rails', '~> 7.0.0'
 gem 'rails-html-sanitizer', '~> 1.4'
-gem 'redis', '~> 5.0'
+gem 'redis', '~> 4.8'
 gem 'rotp', '~> 6.2'
 gem 'sass-rails', '~> 6.0'
 gem 'sprockets', '~> 4.1'
diff --git a/Gemfile.lock b/Gemfile.lock
index 429090e1c67d1c53060b181df8f6d41442a03c23..4bac246fe5d118dfdf86419a81abbaa128a4c627 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -107,7 +107,6 @@ GEM
     coffee-script-source (1.12.2)
     commonmarker (0.23.5)
     concurrent-ruby (1.1.10)
-    connection_pool (2.2.5)
     counter_culture (3.2.1)
       activerecord (>= 4.2)
       activesupport (>= 4.2)
@@ -262,10 +261,7 @@ GEM
     rb-fsevent (0.11.2)
     rb-inotify (0.10.1)
       ffi (~> 1.0)
-    redis (5.0.4)
-      redis-client (>= 0.7.4)
-    redis-client (0.8.0)
-      connection_pool
+    redis (4.8.0)
     regexp_parser (2.5.0)
     responders (3.0.1)
       actionpack (>= 5.0)
@@ -396,7 +392,7 @@ DEPENDENCIES
   rails (~> 7.0.0)
   rails-controller-testing (~> 1.0)
   rails-html-sanitizer (~> 1.4)
-  redis (~> 5.0)
+  redis (~> 4.8)
   reverse_markdown (~> 2.1)
   rmagick
   rotp (~> 6.2)
diff --git a/config/environments/development.rb b/config/environments/development.rb
index b28068a603ceeb7547e4514f14a4f2565c080095..3586b8d5134d4a77bb0f3c2d3726bd809e9e480a 100644
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -24,8 +24,7 @@ Rails.application.configure do
   redis_config = YAML.safe_load(processed, permitted_classes: [], permitted_symbols: [], aliases: true)["redis_#{Rails.env}"]
   config.cache_store = QPixel::NamespacedEnvCache.new(
     ActiveSupport::Cache::RedisCacheStore.new(
-      url: "redis://#{redis_config['host']}:#{redis_config['port']}",
-      inherit_socket: true,
+      **redis_config.deep_symbolize_keys.merge(reconnect_attempts: 3),
       error_handler: -> (method:, returning:, exception:) {
         Rails.logger.error("Cache error: method=#{method} returning=#{returning} exception=#{exception.message}")
       }
diff --git a/config/environments/production.rb b/config/environments/production.rb
index f86b8ec2fc68b95c52eee9c337ff352d0151458e..7a7b6d2d4a42de6a8afcc240e99c9e218c257c81 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -58,9 +58,16 @@ Rails.application.configure do
   # Prepend all log lines with the following tags.
   config.log_tags = [ :subdomain, :uuid ]
 
-  # Use a different cache store in production.
+  # Set the cache store to the redis that was configured in the database.yml
+  processed = ERB.new(File.read(Rails.root.join('config', 'database.yml'))).result(binding)
+  redis_config = YAML.safe_load(processed, permitted_classes: [], permitted_symbols: [], aliases: true)["redis_#{Rails.env}"]
   config.cache_store = QPixel::NamespacedEnvCache.new(
-    ActiveSupport::Cache::RedisCacheStore.new(url: 'redis://localhost:6379/1')
+    ActiveSupport::Cache::RedisCacheStore.new(
+      **redis_config.deep_symbolize_keys.merge(reconnect_attempts: 3),
+      error_handler: -> (method:, returning:, exception:) {
+        Rails.logger.error("Cache error: method=#{method} returning=#{returning} exception=#{exception.message}")
+      }
+    )
   )
 
   # Use a real queuing backend for Active Job (and separate queues per environment).
diff --git a/config/environments/test.rb b/config/environments/test.rb
index 4c5ef5309711a0e4c6fb2a5213cebb2c07ac63b9..8bd2cfad8a20dcb3ba63cd1efd3196a7fb39695c 100644
--- a/config/environments/test.rb
+++ b/config/environments/test.rb
@@ -28,11 +28,15 @@ Rails.application.configure do
   config.consider_all_requests_local       = true
   config.action_controller.perform_caching = false
 
+  # Set the cache store to the redis that was configured in the database.yml
   processed = ERB.new(File.read(Rails.root.join('config', 'database.yml'))).result(binding)
   redis_config = YAML.safe_load(processed, permitted_classes: [], permitted_symbols: [], aliases: true)["redis_#{Rails.env}"]
   config.cache_store = QPixel::NamespacedEnvCache.new(
     ActiveSupport::Cache::RedisCacheStore.new(
-      url: "redis://#{redis_config['host']}:#{redis_config['port']}"
+      **redis_config.deep_symbolize_keys.merge(reconnect_attempts: 3),
+      error_handler: -> (method:, returning:, exception:) {
+        Rails.logger.error("Cache error: method=#{method} returning=#{returning} exception=#{exception.message}")
+      }
     )
   )