{"record":{"id":"72300f713691d7ae","repo":"hashicorp/terraform","slug":"the-request-failed-please-try-again-later-s","errorCode":null,"errorMessage":"the request failed, please try again later%s","messagePattern":"the request failed, please try again later(.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/getproviders/registry_client.go","lineNumber":493,"sourceCode":"\t}\n\n\t// Additional error detail: if we have a response, use the status code;\n\t// if we have an error, use that; otherwise nothing. We will never have\n\t// both response and error.\n\tvar errMsg string\n\tif resp != nil {\n\t\terrMsg = fmt.Sprintf(\": %s returned from %s\", resp.Status, HostFromRequest(resp.Request))\n\t} else if err != nil {\n\t\terrMsg = fmt.Sprintf(\": %s\", err)\n\t}\n\n\t// This function is always called with numTries=RetryMax+1. If we made any\n\t// retry attempts, include that in the error message.\n\tif numTries > 1 {\n\t\treturn resp, fmt.Errorf(\"the request failed after %d attempts, please try again later%s\",\n\t\t\tnumTries, errMsg)\n\t}\n\treturn resp, fmt.Errorf(\"the request failed, please try again later%s\", errMsg)\n}\n\n// HostFromRequest extracts host the same way net/http Request.Write would,\n// accounting for empty Request.Host\nfunc HostFromRequest(req *http.Request) string {\n\tif req.Host != \"\" {\n\t\treturn req.Host\n\t}\n\tif req.URL != nil {\n\t\treturn req.URL.Host\n\t}\n\n\t// this should never happen and if it does\n\t// it will be handled as part of Request.Write()\n\t// https://cs.opensource.google/go/go/+/refs/tags/go1.18.4:src/net/http/request.go;l=574\n\treturn \"\"\n}\n","sourceCodeStart":475,"sourceCodeEnd":511,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/getproviders/registry_client.go#L475-L511","documentation":"Companion to error 944: returned by maxRetryErrorHandler when numTries == 1, i.e. the very first attempt failed with a retryable condition and there were no additional retries. Same trailing detail format. Indicates a single-shot failure rather than an exhausted retry budget.","triggerScenarios":"RetryMax is 0 (no retries configured) or the first response was a hard failure not qualifying for additional attempts; the handler is invoked with numTries=1.","commonSituations":"TF_REGISTRY_DISCOVERY_RETRY unset and the first request hit a 5xx or transport error; environment with retry explicitly disabled; immediate DNS or connection refused.","solutions":["Set TF_REGISTRY_DISCOVERY_RETRY to a positive value to enable retries.","Investigate the trailing error: status code points to registry issue, raw error points to network/TLS.","Retry the command manually once to rule out a one-off blip.","Confirm the registry hostname resolves and is reachable from the host."],"exampleFix":"// before\nError: the request failed, please try again later: connection refused\n// after\n$ export TF_REGISTRY_DISCOVERY_RETRY=5\n$ terraform init","handlingStrategy":"retry","validationCode":null,"typeGuard":"// Detect a single-shot failure (no retries).\nfunc isSingleShotFailure(err error) bool {\n    return err != nil && strings.Contains(err.Error(), \"the request failed,\")\n}","tryCatchPattern":"// On single-shot failure, enable retries and retry once.\nif strings.Contains(err.Error(), \"the request failed,\") {\n    if os.Getenv(\"TF_REGISTRY_DISCOVERY_RETRY\") == \"\" {\n        os.Setenv(\"TF_REGISTRY_DISCOVERY_RETRY\", \"5\")\n    }\n    return retry()\n}","preventionTips":["Always set TF_REGISTRY_DISCOVERY_RETRY in CI to avoid zero-retry failures.","Verify DNS and connectivity before running terraform init.","Use a mirror for air-gapped CI."],"tags":["registry","retry","network","getproviders"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}