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 →

Typical messages
| Message | Cause | Fix |
|---|---|---|
| no available releases match the given constraints ~> 4.0, >= 5.0 | Root and module constraints conflict | Align versions across modules; upgrade the module |
| locked provider ... does not match configured version constraint | .terraform.lock.hcl pins an old version | terraform init -upgrade |
| provider registry.terraform.io/hashicorp/xyz not found | Wrong source, or a partner provider without source | Set source = "namespace/name" in required_providers |
| could not connect to registry.terraform.io / timeout | Proxy, firewall or offline agent | Set HTTPS_PROXY, use a provider mirror or plugin cache |
| checksum ... does not match | Lock file made on another OS/CPU | terraform 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
- Read which provider and constraint failed; run
terraform providersto see every module's requirements. - Make sure every non-HashiCorp provider has an explicit
sourcein every module that uses it. - Loosen or align conflicting constraints, or upgrade the module version that pins the old provider.
- Update the lock file:
terraform init -upgrade, then commit.terraform.lock.hcl. - For teams on Mac (arm64) and Linux CI (amd64), add hashes for both platforms with
terraform providers lock. - Behind a corporate proxy, set
HTTPS_PROXY, or configure a network mirror / filesystem mirror in the CLI config.
Good habits
- Commit
.terraform.lock.hclso everyone and CI get the same provider versions. - Use pessimistic constraints (
~> 5.0) and upgrade deliberately, reading the provider changelog. - Set
TF_PLUGIN_CACHE_DIRon 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.