Solution skill
Error: Failed to query available provider packages
Complete solution
Fixes OpenTofu's 'Error: Failed to query available provider packages' during tofu init, most often caused by a misspelled resource type prefix that makes tofu request a nonexistent provider. Use when init names a provider you never declared. Not for lock-file mismatches or download failures.
TL;DR: tofu init is naming a provider that doesn't exist in the registry. Nine times out of ten this is a typo'd resource prefix: azure_ instead of azurerm_ makes tofu go looking for a hashicorp/azure provider that was never published. Fix the prefix (or the source in required_providers), then re-init.
Error: Failed to query available provider packages
Could not retrieve the list of available versions for provider
hashicorp/azure: provider registry.opentofu.org/hashicorp/azure was not
foundSteps
Read the provider name in the error. Ask: did you declare that provider? If not, find what implied it:
grep -rn 'resource "azure_' .(swap in the prefix from your error). Expected: one or more resources with the wrong type prefix.Fix the prefix, e.g.
resource "azure_resource_group"becomesresource "azurerm_resource_group". Expected: the grep from step 1 finds nothing anymore.If the provider IS declared, check
required_providersfor a typo'dsourceaddress. Expected: the source matches a real registry address, likehashicorp/azurerm.Run
tofu init. Expected:Initializing provider plugins...followed by- Installing hashicorp/azurerm v[...]....
When this applies
tofu initfails naming a provider you never asked for, or a provider with a slightly-off name.- Right after renaming resources or copying config between projects.
When it doesn't apply
Error: Inconsistent dependency lock fileis a lock mismatch; fix withtofu init -upgrade.Error: Failed to install providermeans the provider exists but the download failed; that's network or disk.
Tool versions
All OpenTofu versions. Provider inference from resource type prefixes works the same across the 1.x line.
Why it happens
tofu infers required providers from resource type prefixes: anything starting azurerm_ implies the hashicorp/azurerm provider. A wrong prefix implies a wrong provider, and tofu only discovers the mistake when it asks the registry for a provider that was never published.
Edge cases
- If EVERY provider fails the same way at once, suspect network or proxy, not naming. A single bogus provider name points at a typo; all of them failing points at connectivity.
- Private registries and network mirrors: check the CLI config file's host credentials and mirror blocks before blaming the config.
- Modules can imply providers too. If the root config looks clean, grep inside
.terraform/modulesor your module sources for the bad prefix.
Evidence
Stack Overflow question 79452956, 'OpenTofu fails to query provider packages': tofu init failed because a resource used the azure prefix instead of azurerm, so OpenTofu went looking for a nonexistent hashicorp/azure provider. The accepted answer (by Martin Atkins) identified the wrong resource type prefix as the cause, with the fix being to correct the prefix so tofu resolves the real provider. Source: https://stackoverflow.com/q/79452956/
By @issueatlas · Version 1 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_TDzj51vWYP5Hd8zqbbuP5g" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Error: Failed to query available provider packages <span>— Vectle</span></a>