block/buzz · error · anyhow::Error

Redis pool creation failed

Error message

Redis pool creation failed: {e}

What it means

deadpool_redis::Config::from_url(&redis_url).create_pool() validates the REDIS_URL string and pool settings; it does not open a network connection. It fails when the URL is not a parseable redis URL — missing the redis:// scheme, an unparseable port, a bogus query parameter, or an entirely empty/garbage value (the default fallback is redis://localhost:6379, so hitting this means REDIS_URL was explicitly set to something invalid).

Solutions

  1. Set the scheme explicitly: REDIS_URL=redis://localhost:6379 (rediss:// for TLS).
  2. In docker-compose, point at the service name: REDIS_URL=redis://redis:6379.
  3. Check for trailing whitespace/newlines: printf '%s' "$REDIS_URL" | od -c | head.
  4. Remove unsupported query params or fix them to deadpool-redis's expected format.

Example fix

# before
export REDIS_URL=localhost:6379        # no scheme -> Redis pool creation failed
# after
export REDIS_URL=redis://localhost:6379
Defensive patterns

Strategy: validation

Validate before calling

# require an explicit scheme before running admin commands
case "$REDIS_URL" in
  redis://*|rediss://*) ;;
  "") ;; # default localhost fallback is valid
  *) echo "REDIS_URL must start with redis:// or rediss:// — got: $REDIS_URL" >&2; exit 3 ;;
esac

Prevention

When it happens

Trigger: REDAY_URL/REDIS_URL set to 'localhost:6379' (no scheme), 'redis://localhost:notaport', or containing a trailing newline/space from CI secrets.

Common situations: Docker/k8s env values copied without the scheme; port typos; interpolated secrets with whitespace; using a keydb/valkey URL with unsupported params.

Related errors


AI-assisted analysis of block/buzz@ef2aa1ae38 (2026-08-20). Data as JSON: /api/errors/a75fa7092bef5d43. Report an issue: GitHub.

Appendix: source

Thrown at crates/buzz-admin/src/main.rs:566

    let db = connect_db().await?;

    let relay_keypair = {
        let hex = std::env::var("BUZZ_RELAY_PRIVATE_KEY").map_err(|_| {
            anyhow::anyhow!(
                "BUZZ_RELAY_PRIVATE_KEY is required for add-member/remove-member.\n\
                 The relay must have a stable signing key to publish kind:13534 events."
            )
        })?;
        Keys::parse(&hex).map_err(|e| anyhow::anyhow!("invalid BUZZ_RELAY_PRIVATE_KEY: {e}"))?
    };

    let redis_url =
        std::env::var("REDIS_URL").unwrap_or_else(|_| "redis://localhost:6379".to_string());

    let redis_pool = {
        let cfg = deadpool_redis::Config::from_url(&redis_url);
        cfg.create_pool(Some(deadpool_redis::Runtime::Tokio1))
            .map_err(|e| anyhow::anyhow!("Redis pool creation failed: {e}"))?
    };

    let pubsub = Arc::new(
        PubSubManager::new(&redis_url, redis_pool)
            .await
            .map_err(|e| anyhow::anyhow!("PubSub init failed: {e}"))?,
    );

    Ok((db, pubsub, relay_keypair))
}

async fn connect_db() -> Result<Db> {
    let db_url = std::env::var("DATABASE_URL")
        .unwrap_or_else(|_| "postgres://buzz:buzz_dev@localhost:5432/buzz".to_string());
    let db = Db::new(
        &DbConfig {
            database_url: db_url,
            ..DbConfig::default()

View on GitHub (pinned to ef2aa1ae38)