go-redis/redis · error

redis: invalid URL scheme: %s

Error message

redis: invalid URL scheme: %s

What it means

Error "redis: invalid URL scheme: %s" thrown in go-redis/redis.

Source

Thrown at sentinel.go:438

	}
	return setupFailoverConn(u)
}

func setupFailoverConn(u *url.URL) (*FailoverOptions, error) {
	o := &FailoverOptions{}

	o.SentinelUsername, o.SentinelPassword = getUserPassword(u)

	h, p := getHostPortWithDefaults(u)
	o.SentinelAddrs = append(o.SentinelAddrs, net.JoinHostPort(h, p))

	switch u.Scheme {
	case "rediss":
		o.TLSConfig = &tls.Config{ServerName: h, MinVersion: tls.VersionTLS12}
	case "redis":
		o.TLSConfig = nil
	default:
		return nil, fmt.Errorf("redis: invalid URL scheme: %s", u.Scheme)
	}

	f := strings.FieldsFunc(u.Path, func(r rune) bool {
		return r == '/'
	})
	switch len(f) {
	case 0:
		o.DB = 0
	case 1:
		var err error
		if o.DB, err = strconv.Atoi(f[0]); err != nil {
			return nil, fmt.Errorf("redis: invalid database number: %q", f[0])
		}
	default:
		return nil, fmt.Errorf("redis: invalid URL path: %s", u.Path)
	}

	return setupFailoverConnParams(u, o)

View on GitHub (pinned to 36d97525cd)

Solutions

  1. Use a redis:// or rediss:// scheme in the failover URL
  2. Correct the scheme string in the configuration URL

When it happens

Trigger: Thrown at sentinel.go:438 when the library encounters an invalid state.

Common situations: Validate connection URLs with ParseURL at configuration load time.


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