Skip to content
Latchkey

Terraform Provider Download Fails Transiently During init in CI

A provider or module download stalled or dropped mid-fetch. This is a transient network/registry failure - a brief 5xx or connection reset - that almost always succeeds on a second run.

What this error means

terraform init fails partway through downloading a provider or module with a connection reset, EOF, or 5xx from the registry/object store. Re-running the job usually works unchanged - the hallmark of transient flakiness.

terraform init output
Error: Failed to install provider

Error while installing hashicorp/aws v5.40.0: could not download package:
unexpected EOF
# or
read tcp: connection reset by peer

Common causes

Transient network drop or registry 5xx

A brief connectivity blip or a momentary 5xx from the registry/object store interrupts the download. Nothing is wrong with your configuration.

Congested runner network on a large provider

Big provider archives over a congested runner link can reset mid-transfer, then complete cleanly on retry.

How to fix it

Retry init

Because the failure is transient, a bounded retry around init usually succeeds with no other change.

Terminal
for i in 1 2 3; do terraform init -input=false && break; sleep 10; done

Cache plugins to reduce downloads

A plugin cache means re-runs reuse already-downloaded providers, so a flaky registry matters far less.

Terminal
export TF_PLUGIN_CACHE_DIR="$HOME/.terraform.d/plugin-cache"
terraform init -input=false

How to prevent it

  • Cache the plugin directory (TF_PLUGIN_CACHE_DIR) across runs.
  • Wrap init in a bounded retry for transient registry/network blips.
  • Use a provider mirror on flaky or restricted networks.

Frequently asked questions

What causes "transient provider download fail"?
A brief connectivity blip or a momentary 5xx from the registry/object store interrupts the download. Nothing is wrong with your configuration.
How do I fix transient provider download fail?
Because the failure is transient, a bounded retry around init usually succeeds with no other change.
Can Latchkey fix this automatically?
Yes. Latchkey runs your GitHub Actions on managed runners that detect this failure, apply the fix, and retry the job automatically - self-healing is on by default.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card