{"record":{"id":"b6a659b614aa143d","repo":"kataras/iris","slug":"err-b6a659","errorCode":null,"errorMessage":"err","messagePattern":"err","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"sessions/sessiondb/redis/database.go","lineNumber":115,"sourceCode":"\t\tif c.Timeout < 0 {\n\t\t\tc.Timeout = DefaultRedisTimeout\n\t\t}\n\n\t\tif c.Network == \"\" {\n\t\t\tc.Network = DefaultRedisNetwork\n\t\t}\n\n\t\tif c.Addr == \"\" {\n\t\t\tc.Addr = DefaultRedisAddr\n\t\t}\n\n\t\tif c.Driver == nil {\n\t\t\tc.Driver = GoRedis()\n\t\t}\n\t}\n\n\tif err := c.Driver.Connect(c); err != nil {\n\t\tpanic(err)\n\t}\n\n\tdb := &Database{c: c}\n\t_, err := db.c.Driver.PingPong()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\t// runtime.SetFinalizer(db, closeDB)\n\treturn db\n}\n\n// SetLogger sets the logger once before server ran.\n// By default the Iris one is injected.\nfunc (db *Database) SetLogger(logger *golog.Logger) {\n\tdb.logger = logger\n}\n\nfunc (db *Database) makeSID(sid string) string {","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/kataras/iris/blob/7bedaf55a0b64bbb2248a5845a2c60d81a30996a/sessions/sessiondb/redis/database.go#L97-L133","documentation":"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.).","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\ndb := redis.New(redis.Config{Addr: \"localhost:6379\"}) // panics if Redis is down\n// after\ndrv := redis.GoRedis()\nif err := drv.Connect(redis.Config{Addr: \"localhost:6379\"}); err != nil {\n\tlog.Fatalf(\"redis unavailable: %v\", err)\n}\ndb := redis.New(redis.Config{Addr: \"localhost:6379\", Driver: drv})","handlingStrategy":"try-catch","validationCode":"conn, err := net.DialTimeout(\"tcp\", cfg.Addr, 3*time.Second)\nif err != nil { log.Fatalf(\"redis unreachable: %v\", err) }\nconn.Close()","typeGuard":null,"tryCatchPattern":"func newRedis(cfg redis.Config) (db *redis.Database, err error) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\terr = fmt.Errorf(\"redis.New: %v\", r)\n\t\t}\n\t}()\n\tdb = redis.New(cfg)\n\treturn\n}","preventionTips":["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."],"tags":["redis","network","panic","startup","connection"],"backgroundTag":"connection-refused","analyzedSha":"7bedaf55a0b64bbb2248a5845a2c60d81a30996a","analyzedAt":"2026-08-30T20:38:16.250Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}