{"record":{"id":"08a98255c31674dc","repo":"benbjohnson/litestream","slug":"http-request-w","errorCode":null,"errorMessage":"http request: %w","messagePattern":"http request: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"heartbeat.go","lineNumber":57,"sourceCode":"\t\thttpClient: &http.Client{\n\t\t\tTimeout: timeout,\n\t\t},\n\t}\n}\n\nfunc (c *HeartbeatClient) Ping(ctx context.Context) error {\n\tif c.URL == \"\" {\n\t\treturn nil\n\t}\n\n\treq, err := http.NewRequestWithContext(ctx, http.MethodGet, c.URL, nil)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"create request: %w\", err)\n\t}\n\n\tresp, err := c.httpClient.Do(req)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"http request: %w\", err)\n\t}\n\tdefer resp.Body.Close()\n\n\tif resp.StatusCode < 200 || resp.StatusCode >= 300 {\n\t\treturn fmt.Errorf(\"unexpected status code: %d\", resp.StatusCode)\n\t}\n\n\treturn nil\n}\n\nfunc (c *HeartbeatClient) ShouldPing() bool {\n\tc.mu.Lock()\n\tdefer c.mu.Unlock()\n\treturn time.Since(c.lastPingAt) >= c.Interval\n}\n\nfunc (c *HeartbeatClient) LastPingAt() time.Time {\n\tc.mu.Lock()","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/heartbeat.go#L39-L75","documentation":"HeartbeatClient.Ping() sent the GET request to the heartbeat URL but the HTTP transport failed (connection refused, DNS failure, TLS error, timeout). The request never received a response. This is a network-level failure, not an HTTP status problem.","triggerScenarios":"Calling Ping() when the heartbeat service is down, DNS doesn't resolve the host, a firewall blocks egress, TLS certificate validation fails, or the request exceeds the httpClient timeout.","commonSituations":"Healthchecks.io/dead-man's-snitch outage; litestream running in a restricted network (no egress) such as an air-gapped cluster; corporate proxy required but not configured; typo'd hostname; expired TLS cert on a self-hosted heartbeat endpoint.","solutions":["Verify network egress/DNS from the host running litestream (`curl -v <url>`)","Confirm the heartbeat service URL is correct and the service is up","Check for required proxy configuration (HTTP_PROXY/HTTPS_PROXY) in the environment","If TLS errors occur, fix the endpoint certificate or the CA trust store on the host","Note: heartbeat failure doesn't stop replication; it affects liveness monitoring only — but check whether the caller treats this as fatal"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := hb.Ping(ctx); err != nil {\n    // heartbeat is best-effort: log and retry next interval\n    logger.Warn(\"heartbeat ping failed, will retry\", \"error\", err)\n}","preventionTips":["Ensure egress networking/DNS works from the litestream host","Configure HTTPS_PROXY where corporate proxies are required","Use a heartbeat endpoint with high availability (managed service)","Monitor TLS certificate expiry on self-hosted endpoints"],"tags":["http","network","heartbeat","timeout"],"backgroundTag":"network-request-failed","analyzedSha":"4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3","analyzedAt":"2026-09-06T18:29:25.564Z","contentChangedAt":"2026-09-06T18:29:25.564Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}