{"record":{"id":"5967e0afeff119c2","repo":"dromara/Sa-Token","slug":"can-not-connect-to-redis-host-host-port-cau","errorCode":null,"errorMessage":"can not connect to redis host  {host}:{port} , cause : {e}","messagePattern":"can not connect to redis host  (.+?):(.+?) , cause : (.+?)","errorType":"exception","errorClass":"JbootIllegalConfigException","httpStatus":null,"severity":"critical","filePath":"sa-token-starter/sa-token-jboot-plugin/src/main/java/cn/dev33/satoken/jboot/SaRedisCache.java","lineNumber":249,"sourceCode":"            if (scanKeys != null && scanKeys.size() > 0) {\n                for (String key : scanKeys) {\n                    keys.add(key.substring(3));\n                }\n            }\n\n            if (redisScanResult.isCompleteIteration()) {\n                continueState = false;\n            }\n        } while (continueState);\n\n        return keys;\n    }\n\n    public Jedis getJedis() {\n        try {\n            return jedisPool.getResource();\n        } catch (JedisConnectionException e) {\n            throw new JbootIllegalConfigException(\"can not connect to redis host  \" + config.getHost() + \":\" + config.getPort() + \" ,\" +\n                    \" cause : \" + e, e);\n        }\n    }\n\n\n    public void returnResource(Jedis jedis) {\n        if (jedis != null) {\n            jedis.close();\n        }\n    }\n\n    public RedisScanResult<String> scan(String pattern, String cursor, int scanCount) {\n        ScanParams params = new ScanParams();\n        params.match(pattern).count(scanCount);\n        try (Jedis jedis = getJedis()) {\n            ScanResult<String> scanResult = jedis.scan(cursor, params);\n            return new RedisScanResult<>(scanResult.getCursor(), scanResult.getResult());\n        }","sourceCodeStart":231,"sourceCodeEnd":267,"githubUrl":"https://github.com/dromara/Sa-Token/blob/ac2c7f6e94a78573cf0bcb932dd8b04e68fad189/sa-token-starter/sa-token-jboot-plugin/src/main/java/cn/dev33/satoken/jboot/SaRedisCache.java#L231-L267","documentation":"JbootIllegalConfigException from SaRedisCache.getJedis: borrowing a Jedis client from the pool raised JedisConnectionException, meaning the sa-token jboot plugin could not open a TCP connection to the configured Redis host:port. The cause chain carries the underlying connection error (refused, timeout, auth).","triggerScenarios":"Any sa-token cache operation (login, session read) in a Jboot app whose jboot.redis.host/port points to a Redis that is unreachable, firewalled, or requires a password that was not supplied.","commonSituations":"Redis not started / crashed; wrong host or port in jboot.properties; Docker/K8s networking where 'localhost' does not reach the Redis container; Redis requires a password but jboot.redis.password is empty.","solutions":["Verify reachability from the app host: redis-cli -h <host> -p <port> ping","Correct jboot.redis.host / jboot.redis.port (and password/database) in jboot.properties","In containerized deployments, point to the service name, not localhost, and check the Redis container logs"],"exampleFix":"# before (jboot.properties)\njboot.redis.host=127.0.0.1\njboot.redis.port=6379\n\n# after\njboot.redis.host=redis.internal.example.com\njboot.redis.port=6379\njboot.redis.password=yourpassword","handlingStrategy":"retry","validationCode":"try (Jedis j = new Jedis(host, port)) {\n    j.ping(); // preflight at startup\n} catch (Exception e) {\n    // fail startup with explicit connectivity error\n}","typeGuard":null,"tryCatchPattern":"try { cache.getJedis(); } catch (JbootIllegalConfigException e) { /* backoff and retry; alert if persistent */ }","preventionTips":["Run a Redis connectivity preflight at app startup","Use service DNS names in containers and keep Redis credentials in config management"],"tags":["sa-token","jboot","redis","network","connection"],"backgroundTag":null,"analyzedSha":"ac2c7f6e94a78573cf0bcb932dd8b04e68fad189","analyzedAt":"2026-08-14T14:36:10.271Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}