hashicorp/packer · error
failed to fetch release index: %w
Error message
failed to fetch release index: %w
What it means
The HTTP GET to the Packer releases index endpoint failed at the transport layer: `client.Do(req)` returned an error before any HTTP response was produced. This wraps the underlying net/http error (DNS failure, TCP connect error, TLS handshake failure, or the request context being canceled/timed out).
Source
Thrown at provisioner/hcp-sbom/packer_release_fetch.go:65
Arch string `json:"arch"`
Filename string `json:"filename"`
URL string `json:"url"`
}
// fetchLatestPackerVersion queries the HashiCorp releases index, sorts all
// stable (non-prerelease) versions with semver, and returns the highest one.
func fetchLatestPackerVersion(ctx context.Context, client *http.Client) (string, error) {
indexURL := getReleaseBaseURL() + "/packer/index.json"
var indexData releaseIndex
req, err := http.NewRequestWithContext(ctx, http.MethodGet, indexURL, nil)
if err != nil {
return "", fmt.Errorf("failed to build index request: %w", err)
}
resp, err := client.Do(req)
if err != nil {
return "", fmt.Errorf("failed to fetch release index: %w", err)
}
defer func() { _ = resp.Body.Close() }()
if resp.StatusCode != http.StatusOK {
return "", fmt.Errorf("HTTP %d for %s", resp.StatusCode, indexURL)
}
err = json.NewDecoder(resp.Body).Decode(&indexData)
if err != nil {
return "", fmt.Errorf("failed to retrieve packer release index from %s: %w", indexURL, err)
}
var semverList []*semver.Version
for vStr := range indexData.Versions {
v, parseErr := semver.NewVersion(vStr)
if parseErr != nil {
continue
}View on GitHub (pinned to eb36e3c3e4)
Solutions
- Read the wrapped error to distinguish DNS/connect/TLS/timeout and confirm network egress to https://releases.hashicorp.com/packer/index.json.
- Configure proxy settings (HTTPS_PROXY) if the environment requires a proxy for outbound HTTPS.
- Retry the build — transient network/DNS blips commonly cause this; the caller may already wrap this in packer's retry helper.
- Check status.hashicorp.com for an ongoing releases endpoint outage.
- Ensure the context passed into the provisioner has an adequate deadline.
Example fix
// before: blocked by corporate proxy, no egress export HTTPS_PROXY=http://proxy.corp.example:3128 // after: request succeeds via configured proxy
Defensive patterns
Strategy: retry
Validate before calling
// Pre-flight connectivity check
req, _ := http.NewRequestWithContext(ctx, http.MethodHead, "https://releases.hashicorp.com/packer/index.json", nil)
resp, err := client.Do(req)
if err != nil {
return fmt.Errorf("no egress to releases.hashicorp.com: %w", err)
}
resp.Body.Close() Type guard
func isNetworkError(err error) bool {
var ne net.Error
return err != nil && (errors.As(err, &ne) || errors.Is(err, context.DeadlineExceeded) || errors.Is(err, syscall.ECONNREFUSED))
} Try / catch
var latest string
err := retry.Config{Tries: 3, ShouldRetry: func(err error) bool { return isNetworkError(err) }}.Run(ctx, func(ctx context.Context) error {
var e error
latest, e = fetchLatestPackerVersion(ctx, client)
return e
}) Prevention
- Ensure build environments (CI runners, containers) have outbound HTTPS egress.
- Set HTTPS_PROXY in proxied networks.
- Give the provisioner context a generous deadline.
- Use packer-plugin-sdk/retry for transient network faults.
- Monitor DNS health in your build network.
When it happens
Trigger: fetchLatestPackerVersion calls client.Do on the index request; the error fires when there is no network connectivity to releases.hashicorp.com, DNS resolution fails, a proxy/firewall blocks the connection, TLS fails, or ctx is canceled/deadline exceeded mid-request.
Common situations: CI runner or air-gapped machine without internet egress; corporate proxy required but unset (HTTP(S)_PROXY); transient DNS outage; releases.hashicorp.com incident; build context deadline canceled before the request finished.
Understand the failure class
Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.
Related errors
- HTTP request failed: %w
- failed to download %s: %w
- request GitHub OIDC token: %w
- Error reading checksum file: %s
- failed to build index request: %w
AI-assisted analysis of hashicorp/packer@eb36e3c3e4 (2026-09-05).
Data as JSON: /api/errors/a8f4b7ce5e673c6f.
Report an issue: GitHub.