thanos-io/thanos · error
failed to create redis client
Error message
failed to create redis client
What it means
When the cache type is REDIS, the factory constructs a Redis client via cacheutil.NewRedisClient; failures are wrapped as 'failed to create redis client'. Like the memcached path, this validates configuration (address, auth, timeouts) before any actual connection pool is exercised heavily.
Solutions
- Verify the addresses field points at reachable Redis instances (host:port)
- Add correct username/password/tls settings if Redis requires authentication
- Check timeout and connection-pool fields parse as valid durations/ints
- Inspect the wrapped inner error for the precise invalid parameter
- Test connectivity with redis-cli -h <host> -p <port> from the Thanos pod
Example fix
// before
config:
type: REDIS
redis:
addresses: "6379" # missing host
timeout: soon # invalid duration
// after
config:
type: REDIS
redis:
addresses: "redis.cache.svc:6379"
timeout: 500ms Defensive patterns
Strategy: validation
Validate before calling
for _, a := range redisAddresses {
if _, _, err := net.SplitHostPort(a); err != nil { return fmt.Errorf("bad redis address %q: %w", a, err) }
}
if _, err := time.ParseDuration(redisTimeout); err != nil { return fmt.Errorf("bad redis timeout: %w", err) } Try / catch
cb, err := storecache.NewCachingBucketFromYaml(yamlContent, logger, reg, bucket, router)
if err != nil {
if strings.Contains(err.Error(), "failed to create redis client") {
return fmt.Errorf("redis client config invalid (address/auth/timeouts): %w", err)
}
return err
} Prevention
- Pre-flight test redis-cli connectivity from the Thanos pod
- Supply username/password/TLS when Redis requires auth
- Use valid Go durations for timeout fields
- Keep redis-specific keys under the REDIS cache entry only
When it happens
Trigger: CachingWithBackendConfig.Type == REDIS and NewRedisClient returns an error: invalid or missing Redis address, bad auth config (username/password fields), invalid DB index, malformed timeout values, or an unrecognized client config field.
Common situations: Wrong REDIS address or port, Redis requiring auth but no credentials supplied, TLS settings mismatches, or mixing memcached-style config keys into a Redis cache entry.
Understand the failure class
Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.
Related errors
- failed to parse template
- failed to execute template
- error while parsing config for request logging
- getting http client config
- parsing http config YAML
AI-assisted analysis of thanos-io/thanos@35b8b99117 (2026-09-07).
Data as JSON: /api/errors/4db12019e2c21d18.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/store/cache/caching_bucket_factory.go:134
}
c = cache.NewMemcachedCache("caching-bucket", logger, memcached, reg)
case string(InMemoryBucketCacheProvider):
c, err = cache.NewInMemoryCache("caching-bucket", logger, reg, backendConfig)
if err != nil {
return nil, errors.Wrapf(err, "failed to create inmemory cache")
}
case string(GroupcacheBucketCacheProvider):
const basePath = "/_galaxycache/"
c, err = cache.NewGroupcache(logger, reg, backendConfig, basePath, r, bucket, cfg)
if err != nil {
return nil, errors.Wrap(err, "failed to create groupcache")
}
case string(RedisBucketCacheProvider):
redisCache, err := cacheutil.NewRedisClient(logger, "caching-bucket", backendConfig, reg)
if err != nil {
return nil, errors.Wrapf(err, "failed to create redis client")
}
c = cache.NewRedisCache("caching-bucket", logger, redisCache, reg)
default:
return nil, errors.Errorf("unsupported cache type: %s", config.Type)
}
// Include interactions with cache in the traces.
c = cache.NewTracingCache(c)
cfg.SetCacheImplementation(c)
cb, err := NewCachingBucket(bucket, cfg, logger, reg)
if err != nil {
return nil, err
}
return cb, nil
}
View on GitHub (pinned to 35b8b99117)