block/buzz · critical · anyhow::Error

Redis pool creation failed: {e}

Error message

Redis pool creation failed: {e}

What it means

deadpool-redis builds the application Redis pool from REDIS_URL with the configured redis_pool_size. create_pool validates the URL/config synchronously — failure means the URL could not be parsed into a valid Redis configuration (bad scheme, malformed host/port) — and startup aborts.

Source

Thrown at crates/buzz-relay/src/main.rs:373

    let audit = if config.audit_enabled {
        let audit_pool = sqlx::postgres::PgPoolOptions::new()
            .max_connections(5)
            .min_connections(1)
            .connect(&config.database_url)
            .await
            .map_err(|e| anyhow::anyhow!("Audit DB connection failed: {e}"))?;
        info!("Audit service ready");
        Some(AuditService::new(audit_pool))
    } else {
        info!("Audit logging disabled by BUZZ_AUDIT_ENABLED");
        None
    };

    let redis_pool = {
        let mut cfg = deadpool_redis::Config::from_url(&config.redis_url);
        cfg.pool = Some(deadpool_redis::PoolConfig::new(config.redis_pool_size));
        cfg.create_pool(Some(deadpool_redis::Runtime::Tokio1))
            .map_err(|e| anyhow::anyhow!("Redis pool creation failed: {e}"))?
    };
    let redis_health_pool = redis_pool.clone(); // cheap Arc clone — shared with readiness handler
    let pubsub = Arc::new(
        PubSubManager::new(&config.redis_url, redis_pool)
            .await
            .map_err(|e| anyhow::anyhow!("PubSub init failed: {e}"))?,
    );
    info!("Redis pub/sub connected");

    // Spawn Redis pub/sub subscriber for multi-node fan-out.
    // Events published by other relay instances are received here and
    // fanned out to local WebSocket subscribers.
    let pubsub_for_sub = Arc::clone(&pubsub);
    tokio::spawn(async move { pubsub_for_sub.run_subscriber().await });

    // Spawn Redis pub/sub subscriber for cross-pod cache-key invalidation.
    // Membership / visibility changes on other pods are received here and the
    // matching local moka caches are dropped (via the consumer loop below).

View on GitHub (pinned to f956e6fe06)

Solutions

  1. Set REDIS_URL to a full URL: redis://host:6379 (or rediss:// for TLS)
  2. Add auth or DB index inline when needed: redis://:password@host:6379/0
  3. Lint the URL in the deploy pipeline before starting the relay

Example fix

# before
REDIS_URL=localhost:6379

# after
REDIS_URL=redis://redis:6379
Defensive patterns

Strategy: validation

Validate before calling

# REDIS_URL must parse as a Redis URL.
[[ "${REDIS_URL:-}" =~ ^rediss?://[^/]+ ]] || { echo 'REDIS_URL must start with redis:// or rediss://'; exit 1; }

Prevention

When it happens

Trigger: REDIS_URL missing the scheme (`localhost:6379` instead of `redis://localhost:6379`), an unsupported scheme, or otherwise malformed URL characters.

Common situations: Env templating strips or mangles the scheme; a port pasted into the URL field; values carried between environments by hand.

Related errors


AI-assisted analysis of block/buzz@f956e6fe06 (2026-08-16). Data as JSON: /api/errors/38028323b7205f06. Report an issue: GitHub.