hashicorp/terraform · error

the request failed, please try again later%s

Error message

the request failed, please try again later%s

What it means

maxRetryErrorHandler terminal path when numTries == 1, i.e. RetryMax was 0 so no retries were attempted before giving up. The message omits the attempt count. Same family of cause as 938 (a retryable failure reached the error handler) but with zero retries configured.

Source

Thrown at internal/getproviders/registry_client.go:493

	}

	// Additional error detail: if we have a response, use the status code;
	// if we have an error, use that; otherwise nothing. We will never have
	// both response and error.
	var errMsg string
	if resp != nil {
		errMsg = fmt.Sprintf(": %s returned from %s", resp.Status, HostFromRequest(resp.Request))
	} else if err != nil {
		errMsg = fmt.Sprintf(": %s", err)
	}

	// This function is always called with numTries=RetryMax+1. If we made any
	// retry attempts, include that in the error message.
	if numTries > 1 {
		return resp, fmt.Errorf("the request failed after %d attempts, please try again later%s",
			numTries, errMsg)
	}
	return resp, fmt.Errorf("the request failed, please try again later%s", errMsg)
}

// HostFromRequest extracts host the same way net/http Request.Write would,
// accounting for empty Request.Host
func HostFromRequest(req *http.Request) string {
	if req.Host != "" {
		return req.Host
	}
	if req.URL != nil {
		return req.URL.Host
	}

	// this should never happen and if it does
	// it will be handled as part of Request.Write()
	// https://cs.opensource.google/go/go/+/refs/tags/go1.18.4:src/net/http/request.go;l=574
	return ""
}

View on GitHub (pinned to c9def3e214)

Solutions

  1. Enable retries: set TF_REGISTRY_DISCOVERY_RETRY to a positive value (e.g. 2-5) for the standard client.
  2. If constructing a custom client, set retryableClient.RetryMax > 0.
  3. Increase TF_REGISTRY_CLIENT_TIMEOUT so the single attempt is more likely to succeed.
  4. Verify registry reachability and retry the operation.

Example fix

// before (custom client)
retryableClient.RetryMax = 0
// after
retryableClient.RetryMax = 3
Defensive patterns

Strategy: retry

Validate before calling

// Ensure the standard client has retries enabled (it does by default).
// Override only if you must, and never to 0 in production.
func ensureRetries() {
    if os.Getenv("TF_REGISTRY_DISCOVERY_RETRY") == "" {
        os.Setenv("TF_REGISTRY_DISCOVERY_RETRY", "2")
    }
}

Try / catch

// Same transient pattern as 938; the difference is no retries were configured.
err := withRetry(ctx, func() error { return client.PackageMeta(ctx, p, v, plat) })
if err != nil && strings.Contains(err.Error(), "please try again later") {
    // single-attempt failure; enable retries and retry the operation
}

Prevention

When it happens

Trigger: A retryable registry failure occurred while RetryMax==0. Since configureDiscoveryRetry keeps the default of 1 when TF_REGISTRY_DISCOVERY_RETRY is missing or invalid, reaching numTries==1 means retries were effectively disabled for this client.

Common situations: A custom registryClient constructed with RetryMax=0 in a test/embedded setting; an environment where discovery retry was clamped to 0; a one-shot failure on the very first attempt with no retry budget.

Related errors


AI-assisted analysis of hashicorp/terraform@c9def3e214 (2026-08-07). Data as JSON: /api/errors/72300f713691d7ae. Report an issue: GitHub.