OpenTofu Error: 'Failed to query available provider packages' — Cause, Fix, and Troubleshooting Guide
Fix OpenTofu 'Error: Failed to query available provider packages' from registry outages, air-gapped networks, bad source addresses, or proxy blocks.
- #opentofu
- #iac
- #troubleshooting
- #errors
Stuck on this OpenTofu error? Get the free incident triage checklist
A one-page PDF — the exact steps to isolate, fix, and verify a production error like this one. No spam, unsubscribe anytime.
What this error means
tofu init contacts a provider registry (by default registry.opentofu.org) to discover which versions of each required provider exist and where to download them. If OpenTofu cannot reach the registry, cannot resolve the address, or gets an error response, initialization stops:
Error: Failed to query available provider packages
Could not retrieve the list of available versions for provider
hashicorp/aws: could not connect to registry.opentofu.org: Failed to request
discovery document: Get "https://registry.opentofu.org/.well-known/terraform.json":
dial tcp: lookup registry.opentofu.org: no such host
When it appears
tofu initfails withFailed to query available provider packages.- The detail line names a network problem: DNS failure, connection refused, TLS error, or HTTP 403/404.
- Works on a laptop with internet but fails on a locked-down or air-gapped CI runner.
- Sometimes reports “provider not found” for a mistyped
sourceaddress.
Configuration causes
- No network / DNS — the runner cannot resolve or reach
registry.opentofu.org. - Corporate proxy or firewall blocking the registry or the download CDN.
- Wrong
sourceaddress — typo or a Terraform-only namespace not mirrored in the OpenTofu registry. - Registry outage or rate limiting (HTTP 429).
- Air-gapped environment with no filesystem mirror configured.
Validating the configuration
Read the detail line — it distinguishes DNS, TLS, and HTTP causes:
tofu init 2>&1 | sed -n '1,15p'
Test connectivity to the registry directly:
curl -sSI https://registry.opentofu.org/.well-known/terraform.json
nslookup registry.opentofu.org
Confirm the source addresses you declared:
grep -nA6 'required_providers' *.tf
Check whether a proxy is (or should be) set:
env | grep -i proxy
Resolution
Fix connectivity / proxy so the runner can reach the registry:
export HTTPS_PROXY=http://proxy.example.com:8080
export NO_PROXY=localhost,127.0.0.1
tofu init
Correct the source address to a valid registry namespace:
terraform {
required_providers {
aws = {
source = "hashicorp/aws" # resolves via registry.opentofu.org
version = "~> 5.60"
}
}
}
Use a filesystem mirror in air-gapped setups. First, on a connected machine, mirror the providers:
tofu providers mirror /srv/tofu-providers
Then point OpenTofu at the mirror via CLI config (.tofurc):
provider_installation {
filesystem_mirror {
path = "/srv/tofu-providers"
}
direct { exclude = ["*/*"] }
}
Retry on transient outages/429 with a short backoff before failing the pipeline.
Keeping definitions valid
- The detail line, not the headline, tells you the real cause — always read past the first line.
- Air-gapped CI needs a
filesystem_mirrorornetwork_mirror; direct registry access will never work there. - Provider
sourceaddresses are case-insensitive but must be a real namespace; a typo looks like a network error. - Cache the provider mirror in CI to avoid rate limits and speed up
init. - Set
HTTPS_PROXY/NO_PROXYin the CI environment, not just your shell, or the runner still fails.
Related configuration errors
- OpenTofu Error: ‘Inconsistent dependency lock file’ — Cause, Fix, and Troubleshooting Guide
- OpenTofu Error: ‘Invalid legacy provider address’ — Cause, Fix, and Troubleshooting Guide
- OpenTofu Error: ‘Module not installed’ — Cause, Fix, and Troubleshooting Guide
Fixed it? Get 500 OpenTofu & DevOps AI prompts — free
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.
Did this fix your issue?
Trending errors this week
The error guides other engineers are actually reading right now.
- 1mount: wrong fs type, bad option, bad superblock
- 2Docker 'failed to set up container networking': Fix the Bridge and IP Pool
- 3Docker 'failed to create shim task': How to Fix the containerd Runtime Error
- 4modprobe: FATAL: Module not found
- 5mount: wrong fs type, bad option, bad superblock
- 6Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
Get 500 Battle-Tested DevOps AI Prompts — Free
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.