kataras/iris · critical
err
Error message
err
What it means
redis.New calls Driver.Connect(c) and panics if the connection to the Redis server cannot be established, because the session database is required at startup. The wrapped error is whatever the driver returned (connection refused, auth failure, timeout, etc.).
Source
Thrown at sessions/sessiondb/redis/database.go:115
if c.Timeout < 0 {
c.Timeout = DefaultRedisTimeout
}
if c.Network == "" {
c.Network = DefaultRedisNetwork
}
if c.Addr == "" {
c.Addr = DefaultRedisAddr
}
if c.Driver == nil {
c.Driver = GoRedis()
}
}
if err := c.Driver.Connect(c); err != nil {
panic(err)
}
db := &Database{c: c}
_, err := db.c.Driver.PingPong()
if err != nil {
panic(err)
}
// runtime.SetFinalizer(db, closeDB)
return db
}
// SetLogger sets the logger once before server ran.
// By default the Iris one is injected.
func (db *Database) SetLogger(logger *golog.Logger) {
db.logger = logger
}
func (db *Database) makeSID(sid string) string {View on GitHub (pinned to 7bedaf55a0)
Solutions
- Check the panic's underlying message: fix Addr/Username/Password/Database/TLS fields in redis.Config accordingly.
- Verify Redis is reachable: run redis-cli -h <host> -p <port> ping from the app host.
- If credentials come from env, confirm they are set in the deployment environment.
- Construct the driver yourself (redis.GoRedis()) and call Connect/PingPong to get a recoverable error instead of New's panic.
Example fix
// before
db := redis.New(redis.Config{Addr: "localhost:6379"}) // panics if Redis is down
// after
drv := redis.GoRedis()
if err := drv.Connect(redis.Config{Addr: "localhost:6379"}); err != nil {
log.Fatalf("redis unavailable: %v", err)
}
db := redis.New(redis.Config{Addr: "localhost:6379", Driver: drv}) Defensive patterns
Strategy: try-catch
Validate before calling
conn, err := net.DialTimeout("tcp", cfg.Addr, 3*time.Second)
if err != nil { log.Fatalf("redis unreachable: %v", err) }
conn.Close() Try / catch
func newRedis(cfg redis.Config) (db *redis.Database, err error) {
defer func() {
if r := recover(); r != nil {
err = fmt.Errorf("redis.New: %v", r)
}
}()
db = redis.New(cfg)
return
} Prevention
- Health-check Redis in readiness probes before app start.
- Load Redis credentials from env with validation at boot.
- Pin Addr/Password per environment (dev/stage/prod) via config.
When it happens
Trigger: redis.New(redis.Config{Addr: ...}) where the Redis host/port is wrong, the server is down, a password is required/incorrect, or TLS settings mismatch.
Common situations: Redis not running locally (default 127.0.0.1:6379), Docker network/DNS issues, WRONGPASS after rotating credentials, or firewall blocking the port in staging/production.
Understand the failure class
Background: ECONNREFUSED and "connection refused" / "could not connect to server" errors: what they mean and how to fix them — this error's family across 44 libraries.
Related errors
- failed to connect to the server after %d retries
- failed to connect to the server after %d retries
- panic(err)
- unsupported type of map: %T
- err
AI-assisted analysis of kataras/iris@7bedaf55a0 (2026-08-30).
Data as JSON: /api/errors/b6a659b614aa143d.
Report an issue: GitHub.