block/buzz · error

PubSub init failed: {e}

Error message

PubSub init failed: {e}

What it means

PubSubManager::new(redis_url, pool) failed inside connect_member_services(). Unlike pool creation (which only validates config), PubSubManager establishes the actual Redis pub/sub connection, so this error means the Redis server at REDIS_URL (default redis://localhost:6379) could not be reached or authenticated — connection refused, DNS failure, timeouts, or wrong credentials. The underlying error string is included as {e}.

Source

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

                 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()
    })
    .await?;
    Ok(db)
}

/// Resolve the deployment's tenant from the configured `RELAY_URL` host.
///

View on GitHub (pinned to f956e6fe06)

Solutions

  1. Start Redis and confirm reachability: `redis-cli -u "$REDIS_URL" ping` should return PONG before re-running buzz-admin.
  2. If Redis requires auth/TLS, embed credentials in the URL: redis://:password@host:6379 or rediss://… for TLS.
  3. Fix the host/port in REDIS_URL (or unset it to use the localhost:6379 default when running the dev stack via `just relay`).
  4. Check the {e} suffix: 'Connection refused' → Redis not listening on that interface; 'DNS resolution' → wrong hostname; 'AuthenticationError' → missing password/ACL mismatch.

Example fix

# before: redis not running
$ buzz-admin add-member ...
error: PubSub init failed: ... Connection refused (os error 111)

# after: start the dev stack (Postgres + Redis), then retry
$ just relay &   # or: docker run -p 6379:6379 redis:7
$ redis-cli ping
PONG
$ buzz-admin add-member ...
Defensive patterns

Strategy: retry

Validate before calling

# preflight: Redis must answer PING before running admin member commands
redis-cli -u "${REDIS_URL:-redis://localhost:6379}" ping >/dev/null 2>&1 \
  || { echo "Redis at ${REDIS_URL:-redis://localhost:6379} is unreachable" >&2; exit 1; }

Try / catch

for attempt in 1 2 3; do buzz-admin add-member ... && break; sleep $((attempt*2)); done # safe to retry: the command fails before mutating state if pubsub init fails

Prevention

When it happens

Trigger: Running buzz-admin add-member/remove-member while the local Redis container is stopped (`just relay` / docker compose not up), pointing REDAY_URL/REDIS_URL at a remote Redis that is firewalled or requires a password, or a Redis requiring AUTH where the URL has no password.

Common situations: Fresh checkout where only Postgres was started; running the admin CLI on a workstation against a staging Redis that needs VPN/TLS; Redis restarted between the relay starting and the admin command; REDIS_URL pointing at a stale container IP.

Related errors


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