terraform network_error ai_generated true

Error: Failed to query available provider packages: could not retrieve the list of available versions for provider hashicorp/aws: the registry at registry.terraform.io did not respond

ID: terraform/invalid-provider-registry-source

Also available as: JSON · Markdown · 中文
85%Fix Rate
87%Confidence
1Evidence
2023-03-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
Terraform 1.4 active
Terraform 1.5 active
Terraform 1.6 active
Terraform 1.7 active

Root Cause

Terraform cannot reach the Terraform Registry (registry.terraform.io) to fetch provider metadata, often due to network issues, DNS failures, or proxy misconfiguration.

generic

中文

Terraform 无法访问 Terraform Registry (registry.terraform.io) 来获取提供程序元数据,通常是由于网络问题、DNS 故障或代理配置错误。

Official Documentation

https://developer.hashicorp.com/terraform/cli/config/environment-variables

Workarounds

  1. 90% success Check network connectivity: curl -v https://registry.terraform.io/.well-known/terraform.json
    Check network connectivity: curl -v https://registry.terraform.io/.well-known/terraform.json
  2. 95% success Use a local provider mirror or filesystem mirror: terraform init -plugin-dir=/path/to/mirror
    Use a local provider mirror or filesystem mirror: terraform init -plugin-dir=/path/to/mirror
  3. 75% success Set TF_REGISTRY_DISCOVERY_RETRY=3 to increase retry attempts: export TF_REGISTRY_DISCOVERY_RETRY=3 && terraform init
    Set TF_REGISTRY_DISCOVERY_RETRY=3 to increase retry attempts: export TF_REGISTRY_DISCOVERY_RETRY=3 && terraform init

中文步骤

  1. Check network connectivity: curl -v https://registry.terraform.io/.well-known/terraform.json
  2. Use a local provider mirror or filesystem mirror: terraform init -plugin-dir=/path/to/mirror
  3. Set TF_REGISTRY_DISCOVERY_RETRY=3 to increase retry attempts: export TF_REGISTRY_DISCOVERY_RETRY=3 && terraform init

Dead Ends

Common approaches that don't work:

  1. 80% fail

    Using a non-existent or misconfigured proxy worsens connectivity.

  2. 40% fail

    This is an extreme measure that compromises security and may not solve DNS issues.