{"record":{"id":"32dae0cb5f4dd657","repo":"dgraph-io/dgraph","slug":"please-retry-again-server-is-not-ready-to-accept","errorCode":null,"errorMessage":"Please retry again, server is not ready to accept requests","messagePattern":"Please retry again, server is not ready to accept requests","errorType":"http","errorClass":null,"httpStatus":503,"severity":"warning","filePath":"x/health.go","lineNumber":23,"sourceCode":"\npackage x\n\nimport (\n\t\"sync/atomic\"\n\n\t\"github.com/golang/glog\"\n\t\"github.com/pkg/errors\"\n)\n\nvar (\n\t// the drainingMode variable should be accessed through the atomic.Store and atomic.Load\n\t// functions. The value 0 means the draining-mode is disabled, and the value 1 means the\n\t// mode is enabled\n\tdrainingMode              uint32\n\textSnapshotStreamingState uint32\n\n\thealthCheck     uint32\n\terrHealth       = errors.New(\"Please retry again, server is not ready to accept requests\")\n\terrDrainingMode = errors.New(\"the server is in draining mode \" +\n\t\t\"and client requests will only be allowed after exiting the mode \" +\n\t\t\" by sending a GraphQL draining(enable: false) mutation to /admin\")\n)\n\n// UpdateHealthStatus updates the server's health status so it can start accepting requests.\nfunc UpdateHealthStatus(ok bool) {\n\tsetStatus(&healthCheck, ok)\n}\n\n// UpdateDrainingMode updates the server's draining mode\nfunc UpdateDrainingMode(enable bool) {\n\tsetStatus(&drainingMode, enable)\n}\n\n// ExtSnapshotStreamingState updates the server's import mode\nfunc ExtSnapshotStreamingState(enable bool) {\n\tglog.Info(\"[import] Updating import mode to \", enable)","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/x/health.go#L5-L41","documentation":"errHealth is a package-level sentinel error returned while the server's healthCheck flag is not set, i.e. the server has not finished initializing (or is shutting down) and cannot accept requests. HealthCheck returns it and client-facing entry points (such as NewMinioClient setup paths that gate on health) surface it so callers know to retry rather than treat the operation as failed permanently.","triggerScenarios":"Sending a request before UpdateHealthStatus(true) has been called after alpha startup; probing HealthCheck during initialization, config load, or drain shutdown; calling NewMinioClient before the server is ready.","commonSituations":"Load balancers / health probes hitting an alpha seconds after start; orchestration (Kubernetes) starting clients before the server is ready; requests during a restart window.","solutions":["Wait for the server to finish startup and begin accepting requests (health endpoint returns OK) before sending requests","Retry the request with exponential backoff — this error is explicitly transient","Check server logs for why startup is stalled (bad config, pending Raft connection, slow WAL replay)","Fix readiness probes so traffic is only routed once UpdateHealthStatus(true) ran"],"exampleFix":"// before\nclient := NewMinioClient(...) // returns errHealth right after alpha start\n// after\nfor i := 0; i < 30; i++ {\n    if err := HealthCheck(); err == nil {\n        break\n    }\n    time.Sleep(2 * time.Second) // retry until server is ready\n}\nclient := NewMinioClient(...)","handlingStrategy":"retry","validationCode":"// Gate work on the health endpoint before issuing requests\nif err := x.HealthCheck(); err != nil {\n    // server not ready yet — defer/start retry loop\n}","typeGuard":null,"tryCatchPattern":"err := doRequest(client)\nif err != nil && strings.Contains(err.Error(), \"server is not ready\") {\n    time.Sleep(backoff) // exponential backoff, bounded retries\n    err = doRequest(client)\n}","preventionTips":["Add readiness probes that only route traffic once the server reports healthy","Start clients only after the alpha's health endpoint returns OK","Use bounded exponential-backoff retries for this explicitly transient error","Watch startup logs to distinguish 'still starting' from a wedged startup"],"tags":["health-check","server-startup","retry","transient"],"backgroundTag":"server-not-ready","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}