{"id":"4cd8695031d8442f","repo":"docker/cli","slug":"timeout-waiting-for-stats","errorCode":null,"errorMessage":"timeout waiting for stats","messagePattern":"timeout waiting for stats","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"cli/command/container/stats_helpers.go","lineNumber":154,"sourceCode":"\t\t\t\t\tNetworkRx:        netRx,\n\t\t\t\t\tNetworkTx:        netTx,\n\t\t\t\t\tBlockRead:        float64(blkRead),\n\t\t\t\t\tBlockWrite:       float64(blkWrite),\n\t\t\t\t\tPidsCurrent:      v.PidsStats.Current,\n\t\t\t\t})\n\t\t\t}\n\t\t\tu <- nil\n\t\t\tif !streamStats {\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}()\n\tfor {\n\t\tselect {\n\t\tcase <-time.After(2 * time.Second):\n\t\t\t// zero out the values if we have not received an update within\n\t\t\t// the specified duration.\n\t\t\ts.SetErrorAndReset(errors.New(\"timeout waiting for stats\"))\n\t\t\t// if this is the first stat you get, release WaitGroup\n\t\t\tif !getFirst {\n\t\t\t\tgetFirst = true\n\t\t\t\twaitFirst.Done()\n\t\t\t}\n\t\tcase err := <-u:\n\t\t\ts.SetError(err)\n\t\t\tif errors.Is(err, io.EOF) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif err != nil {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\t// if this is the first stat you get, release WaitGroup\n\t\t\tif !getFirst {\n\t\t\t\tgetFirst = true\n\t\t\t\twaitFirst.Done()\n\t\t\t}","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/cli/command/container/stats_helpers.go#L136-L172","documentation":"Set by the stats collector goroutine in cli/command/container/stats_helpers.go when no stats sample arrives from the daemon's ContainerStats stream within 2 seconds. The `docker stats` display shows this per-container error state and zeroes the row's values; it also releases the wait group so a slow container cannot hang the whole table. It indicates a slow or stalled stats stream, not necessarily a dead container.","triggerScenarios":"The select's 2-second time.After fires before a decoded stats message lands on the update channel: daemon under heavy load, containers on a slow/remote DOCKER_HOST connection, a very large number of containers being streamed at once, a paused/wedged containerd shim, or cgroup stats collection stalling on the host.","commonSituations":"Remote daemons over high-latency links (ssh:// or TCP contexts); hosts under CPU/IO pressure where cgroup reads are slow; rootless or VM-based setups (Docker Desktop) with an overloaded VM; huge fleets where `docker stats` with no arguments streams hundreds of containers.","solutions":["Check daemon health and load on the Docker host (top, dockerd/containerd logs) — the stream is stalling server-side","If using a remote DOCKER_HOST/context, test latency and retry locally; slow links routinely miss the 2s window","Limit scope to fewer containers: docker stats ctr1 ctr2 instead of streaming everything","Try a one-shot snapshot with docker stats --no-stream to see whether any sample arrives at all","Restart dockerd/containerd if a specific container's stats stream is permanently wedged"],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":["docker-cli","container","stats","timeout","daemon-performance"],"analyzedSha":"e9452d6e785f6e365712b9d71bd7517591773c86","analyzedAt":"2026-08-01T07:09:22.474Z","schemaVersion":2}