Resolving OpenTofu provider schema errors after migration from Terraform
Last updated: September 9, 2025
When using OpenTofu after migrating from Terraform, you may encounter provider schema errors during the plan phase, particularly for stacks where no changes were applied in the previous version.
Common Error Message
You might see errors like:
Error: Failed to load plugin schemas
Error while loading schemas for plugin components: 2 problems:
- Failed to obtain provider schema: Could not load the schema for provider
registry.terraform.io/hashicorp/aws: failed to instantiate provider
"registry.terraform.io/hashicorp/aws" to obtain schema: unavailable
provider "registry.terraform.io/hashicorp/aws".Root Cause
This issue is related to how OpenTofu handles provider source URLs in the state file. The problem typically occurs when:
Stacks have not had their state updated by OpenTofu
Provider sources include the full registry URL (e.g.,
registry.terraform.io/hashicorp/aws)
Solution
There are two approaches to resolve this issue:
Option 1: Update the State File
Run a successful tofu apply operation on the affected stacks. Any changes to the state file made by OpenTofu will resolve the schema loading issue. Even running tofu show after a successful apply will work correctly.
Option 2: Remove Registry Hostname from Provider Sources
In your Terraform configuration files, remove the registry.terraform.io hostname from provider source declarations.
Change from:
source = "registry.terraform.io/hashicorp/aws"To:
source = "hashicorp/aws"Why This Happens
Stacks with unchanged state files may still contain provider references that are incompatible with the newer OpenTofu version's schema loading mechanism.