go-redis/redis · error

failed to create credentials listener: %w

Error message

failed to create credentials listener: %w

What it means

Error "failed to create credentials listener: %w" thrown in go-redis/redis.

Source

Thrown at redis.go:746

	// and to guard the user-visible OnConnect callback below.
	conn.baseClient.cscActive = c.cscActive
	// This internal conn's init pipeline issues CLIENT TRACKING ON itself;
	// exempt it from the guard that blocks user-issued CLIENT TRACKING. Setting
	// the field after newConn is safe: initHooks bound the pipeline hook as a
	// method value on the addressable baseClient, so the guard reads the
	// updated field.
	conn.baseClient.allowClientTracking = true

	username, password := "", ""
	if c.opt.StreamingCredentialsProvider != nil {
		credListener, initErr := c.streamingCredentialsManager.Listener(
			cn,
			c.reAuthConnection(),
			c.onAuthenticationErr(),
		)
		if initErr != nil {
			cn.GetStateMachine().Transition(pool.StateClosed)
			return fmt.Errorf("failed to create credentials listener: %w", initErr)
		}

		credentials, unsubscribeFromCredentialsProvider, initErr := c.opt.StreamingCredentialsProvider.
			Subscribe(credListener)
		if initErr != nil {
			cn.GetStateMachine().Transition(pool.StateClosed)
			return fmt.Errorf("failed to subscribe to streaming credentials: %w", initErr)
		}

		// Per-connection unsubscribe is attached to the connection itself so it
		// runs when this specific connection is closed. Do not register it on
		// c.onClose: initConn runs for every (re)initialized connection, and
		// attaching per-connection state to the shared baseClient registry would
		// either leak entries (one per connection id, never trimmed) or — with
		// the pre-fix wrappedOnClose approach — build an unbounded closure chain
		// retaining every prior connection's unsubscribe (see issue #3772).
		//
		// Note: pool.Conn.SetOnClose OVERWRITES any prior callback (see the

View on GitHub (pinned to 36d97525cd)

Solutions

  1. Inspect the wrapped error from the credentials listener creation
  2. Verify the streaming credentials provider is correctly configured (e.g. Entra ID setup)

When it happens

Trigger: Thrown at redis.go:746 when the library encounters an invalid state.

Common situations: Validate credentials provider configuration at startup before constructing the client.


AI-assisted analysis of go-redis/redis@36d97525cd (2026-08-06). Data as JSON: /data/errors/72a457cf99b98d37.json. Report an issue: GitHub.