infiniflow/ragflow · critical · Exception
Lost connection!
Error message
Lost connection!
What it means
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.
Source
Thrown at api/apps/restful_apis/system_api.py:154
try:
KnowledgebaseService.get_by_id("x")
res["database"] = {
"database": settings.DATABASE_TYPE.lower(),
"status": "green",
"elapsed": "{:.1f}".format((timer() - st) * 1000.0),
}
except Exception as e:
res["database"] = {
"database": settings.DATABASE_TYPE.lower(),
"status": "red",
"elapsed": "{:.1f}".format((timer() - st) * 1000.0),
"error": str(e),
}
st = timer()
try:
if not REDIS_CONN.health():
raise Exception("Lost connection!")
res["redis"] = {
"status": "green",
"elapsed": "{:.1f}".format((timer() - st) * 1000.0),
}
except Exception as e:
res["redis"] = {
"status": "red",
"elapsed": "{:.1f}".format((timer() - st) * 1000.0),
"error": str(e),
}
task_executor_heartbeats = {}
try:
task_executors = REDIS_CONN.smembers("TASKEXE")
now = datetime.now().timestamp()
for task_executor_id in task_executors:
heartbeats = REDIS_CONN.zrangebyscore(task_executor_id, now - 60 * 30, now)
heartbeats = [json.loads(heartbeat) for heartbeat in heartbeats]View on GitHub (pinned to 554fb1133a)
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.
Defensive patterns
Strategy: fallback
Validate before calling
from rag.utils.redis_conn import REDIS_CONN
def redis_ready():
try:
return bool(REDIS_CONN.health())
except Exception:
return False
assert redis_ready(), "Redis unavailable - start docker/docker-compose-base.yml before running workers" Try / catch
try:
health = await get_system_health()
except Exception:
health = {"redis": {"status": "red"}}
if health.get("redis", {}).get("status") != "green":
alert_ops("Redis down - task queue and sessions degraded") Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Related errors
AI-assisted analysis of infiniflow/ragflow@554fb1133a (2026-08-15).
Data as JSON: /api/errors/d78c490f3fa3837a.
Report an issue: GitHub.