{"record":{"id":"d78c490f3fa3837a","repo":"infiniflow/ragflow","slug":"lost-connection","errorCode":null,"errorMessage":"Lost connection!","messagePattern":"Lost connection!","errorType":"http","errorClass":"Exception","httpStatus":null,"severity":"critical","filePath":"api/apps/restful_apis/system_api.py","lineNumber":154,"sourceCode":"    try:\n        KnowledgebaseService.get_by_id(\"x\")\n        res[\"database\"] = {\n            \"database\": settings.DATABASE_TYPE.lower(),\n            \"status\": \"green\",\n            \"elapsed\": \"{:.1f}\".format((timer() - st) * 1000.0),\n        }\n    except Exception as e:\n        res[\"database\"] = {\n            \"database\": settings.DATABASE_TYPE.lower(),\n            \"status\": \"red\",\n            \"elapsed\": \"{:.1f}\".format((timer() - st) * 1000.0),\n            \"error\": str(e),\n        }\n\n    st = timer()\n    try:\n        if not REDIS_CONN.health():\n            raise Exception(\"Lost connection!\")\n        res[\"redis\"] = {\n            \"status\": \"green\",\n            \"elapsed\": \"{:.1f}\".format((timer() - st) * 1000.0),\n        }\n    except Exception as e:\n        res[\"redis\"] = {\n            \"status\": \"red\",\n            \"elapsed\": \"{:.1f}\".format((timer() - st) * 1000.0),\n            \"error\": str(e),\n        }\n\n    task_executor_heartbeats = {}\n    try:\n        task_executors = REDIS_CONN.smembers(\"TASKEXE\")\n        now = datetime.now().timestamp()\n        for task_executor_id in task_executors:\n            heartbeats = REDIS_CONN.zrangebyscore(task_executor_id, now - 60 * 30, now)\n            heartbeats = [json.loads(heartbeat) for heartbeat in heartbeats]","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/api/apps/restful_apis/system_api.py#L136-L172","documentation":"Raised by the system health endpoint when REDIS_CONN.health() returns falsy — the Redis connection is unusable. The endpoint does not rethrow; it records status 'red' with the error text, so this message marks the Redis component of the health report as down.","triggerScenarios":"GET on the system/health endpoint while Redis is stopped, unreachable (network/firewall), credentials are wrong, or the connection pool was exhausted/never initialized (REDIS_CONN not connected at startup).","commonSituations":"docker compose base stack not started or redis container crashed; wrong REDIS_HOST/REDIS_PASSWORD in service_conf; Redis restarting during upgrades; heavy task queues exhausting maxclients.","solutions":["Start or restart Redis: docker compose -f docker/docker-compose-base.yml up -d and check `docker logs <redis-container>`.","Verify REDIS_HOST/REDIS_PORT/REDIS_PASSWORD in docker/service_conf.yaml match the deployed Redis.","Test connectivity from the API container: redis-cli -h <host> ping.","Check Redis maxclients/memory limits if the pool is exhausted under load."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"from rag.utils.redis_conn import REDIS_CONN\n\ndef redis_ready():\n    try:\n        return bool(REDIS_CONN.health())\n    except Exception:\n        return False\n\nassert redis_ready(), \"Redis unavailable - start docker/docker-compose-base.yml before running workers\"","typeGuard":null,"tryCatchPattern":"try:\n    health = await get_system_health()\nexcept Exception:\n    health = {\"redis\": {\"status\": \"red\"}}\nif health.get(\"redis\", {}).get(\"status\") != \"green\":\n    alert_ops(\"Redis down - task queue and sessions degraded\")","preventionTips":["Wire the health endpoint into uptime monitoring with alerting on redis=red.","Use docker compose depend_on/healthchecks so the API waits for Redis.","Keep REDIS_* settings identical across API and worker replicas."],"tags":["system-api","health-check","redis","infrastructure"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}