Error fixTerraform · 3 min read · Updated 6 Dec 2026

Terraform init "Failed to query available provider packages": Fix

Fix terraform init provider errors: version constraints that do not match, the lock file, registry or proxy problems, and wrong provider source addresses.

QUICK ANSWERWhen terraform init fails with "Failed to query available provider packages" or "no available releases match the given constraints", Terraform could not find or download a provider version that satisfies every required_providers constraint and the dependency lock file. Fix the source address or version constraint, run terraform init -upgrade to update the lock file, and check network, proxy or registry access.

Learn this hands-on: covered in Week 2: Terraform basics: providers, resources and state of our 12-week Terraform Associate course, with live labs and a trainer to help. See the full syllabus →

Terraform init provider errors: causes and fixes
Terraform init provider errors: causes and fixes

Typical messages

MessageCauseFix
no available releases match the given constraints ~> 4.0, >= 5.0Root and module constraints conflictAlign versions across modules; upgrade the module
locked provider ... does not match configured version constraint.terraform.lock.hcl pins an old versionterraform init -upgrade
provider registry.terraform.io/hashicorp/xyz not foundWrong source, or a partner provider without sourceSet source = "namespace/name" in required_providers
could not connect to registry.terraform.io / timeoutProxy, firewall or offline agentSet HTTPS_PROXY, use a provider mirror or plugin cache
checksum ... does not matchLock file made on another OS/CPUterraform providers lock -platform=linux_amd64 -platform=darwin_arm64

A correct provider block

terraform {
  required_version = ">= 1.6"
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 5.0"   # any 5.x, not 6.0
    }
  }
}

Fix it step by step

  1. Read which provider and constraint failed; run terraform providers to see every module's requirements.
  2. Make sure every non-HashiCorp provider has an explicit source in every module that uses it.
  3. Loosen or align conflicting constraints, or upgrade the module version that pins the old provider.
  4. Update the lock file: terraform init -upgrade, then commit .terraform.lock.hcl.
  5. For teams on Mac (arm64) and Linux CI (amd64), add hashes for both platforms with terraform providers lock.
  6. Behind a corporate proxy, set HTTPS_PROXY, or configure a network mirror / filesystem mirror in the CLI config.

Good habits

  • Commit .terraform.lock.hcl so everyone and CI get the same provider versions.
  • Use pessimistic constraints (~> 5.0) and upgrade deliberately, reading the provider changelog.
  • Set TF_PLUGIN_CACHE_DIR on CI agents to avoid downloading providers on every run.

Questions

Should I commit the .terraform folder?

No. Commit .terraform.lock.hcl, but add .terraform/ to .gitignore.

What does ~> 5.0 mean?

Any version 5.x (>= 5.0 and < 6.0). ~> 5.4.0 would allow only 5.4.x.