we-promise/sure · warning

REDIS_SENTINEL_HOSTS is set but no valid sentinel hosts foun

Error message

REDIS_SENTINEL_HOSTS is set but no valid sentinel hosts found, falling back to REDIS_URL

What it means

The Sidekiq initializer parses REDIS_SENTINEL_HOSTS as a comma-separated host[:port] list; each entry is split on ":", stripped, and dropped when the host part is blank (filter_map with next if host.blank?). Ports out of range are coerced to 26379, but blank hosts remove the entry. If every entry is dropped, the sentinel list is empty, the initializer warns, and Sidekiq silently falls back to a plain REDIS_URL connection (default redis://localhost:6379/0), bypassing Sentinel HA entirely.

Source

Thrown at config/initializers/sidekiq.rb:41

    parts = host_port.strip.split(":", 2)
    host = parts[0]&.strip
    port_str = parts[1]&.strip

    next if host.blank?

    # Parse port with validation, default to 26379 if invalid or missing
    port = if port_str.present?
      port_int = port_str.to_i
      (port_int > 0 && port_int <= 65535) ? port_int : 26379
    else
      26379
    end

    { host: host, port: port }
  end

  if sentinels.empty?
    Rails.logger.warn("REDIS_SENTINEL_HOSTS is set but no valid sentinel hosts found, falling back to REDIS_URL")
    { url: ENV.fetch("REDIS_URL", "redis://localhost:6379/0") }
  else
    {
      url: "redis://#{ENV.fetch('REDIS_SENTINEL_MASTER', 'mymaster')}/0",
      sentinels: sentinels,
      password: ENV["REDIS_PASSWORD"],
      sentinel_username: ENV.fetch("REDIS_SENTINEL_USERNAME", "default"),
      sentinel_password: ENV["REDIS_PASSWORD"],
      role: :master,
      # Recommended timeouts for Sentinel
      connect_timeout: 0.2,
      read_timeout: 1,
      write_timeout: 1,
      reconnect_attempts: 3
    }
  end
else
  # Standard Redis URL configuration (no Sentinel)

View on GitHub (pinned to e69894adb9)

Solutions

  1. Set REDIS_SENTINEL_HOSTS to a proper comma-separated list of host:port pairs, e.g. sentinel1:26379,sentinel2:26379,sentinel3:26379
  2. Print the variable in the app's environment (rails runner 'puts ENV["REDIS_SENTINEL_HOSTS"].inspect') to expose stray quotes, semicolons, or comma-only content
  3. If Sentinel is not intended, unset REDIS_SENTINEL_HOSTS entirely and configure REDIS_URL instead so the fallback is the real configuration
  4. When Sentinel is intended, also set REDIS_SENTINEL_MASTER (default mymaster) and REDIS_PASSWORD so the sentinel config block is complete

Example fix

# .env - before
REDIS_SENTINEL_HOSTS=,,

# .env - after
REDIS_SENTINEL_HOSTS=sentinel1:26379,sentinel2:26379,sentinel3:26379
REDIS_SENTINEL_MASTER=mymaster
REDIS_PASSWORD=secret
Defensive patterns

Strategy: validation

Validate before calling

# Validate sentinel host parsing before Sidekiq boots (initializer or rake task)
if (raw = ENV["REDIS_SENTINEL_HOSTS"]).present?
  hosts = raw.split(",").filter_map { |e| e.strip.split(":", 2)[0]&.strip }.reject(&:blank?)
  if hosts.empty?
    raise "REDIS_SENTINEL_HOSTS='#{raw}' contains no valid hosts - fix or unset it (it currently falls back to REDIS_URL)"
  end
end

Prevention

When it happens

Trigger: REDIS_SENTINEL_HOSTS is set to a value that contains no usable host: ",", " , , ", ";", a value made only of port fragments like ":26379", or a quoted comma artifact like '","' from templating. Any single non-blank host (even misspelled) would produce a sentinel entry instead, so this warning specifically means all entries had blank host parts (config/initializers/sidekiq.rb:22-42).

Common situations: docker-compose/Kubernetes templating that interpolates an empty variable leaving placeholder commas; secret managers injecting an empty or comma-only string; switching a deployment from Sentinel to plain Redis and leaving a stray value; environment files where the variable name is duplicated and one instance is empty.

Related errors


AI-assisted analysis of we-promise/sure@e69894adb9 (2026-08-21). Data as JSON: /api/errors/3b8fd0bf74175d4e. Report an issue: GitHub.