Error: Could not load plugin for terraform 0.14.3

We are getting below error for our provider

Error: Could not load plugin
Plugin reinitialization required. Please run "terraform init".
Plugins are external binaries that Terraform uses to access and manipulate
resources. The configuration provided requires plugins which can't be located,
don't satisfy the version constraints, or are otherwise incompatible.
Terraform automatically discovers provider requirements from your
configuration, including providers used in child modules. To see the
requirements and constraints, run "terraform providers".
Failed to instantiate provider "registry.terraform.io/hashicorp/aws" to obtain
schema: unknown provider "registry.terraform.io/hashicorp/aws"
Authenticating with credentials from /root/.docker/config.json

although we have also replaced the provider

terraform state replace-provider -auto-approve registry.terraform.io/-/aws registry.terraform.io/hashicorp/aws 
terraform state replace-provider -auto-approve registry.terraform.io/-/external   registry.terraform.io/hashicorp/external
terraform state replace-provider -auto-approve registry.terraform.io/-/null   registry.terraform.io/hashicorp/null
terraform state replace-provider -auto-approve registry.terraform.io/-/random   registry.terraform.io/hashicorp/random
terraform state replace-provider -auto-approve registry.terraform.io/-/template  registry.terraform.io/hashicorp/template

apart from this we had also used required_providers but no luck please suggest

 required_providers {
        aws = {
        source = "hashicorp/aws"
        version = "3.49.0"
      }
  

Hi @dewshekhar,

Can you also include the result of running terraform init? I think that’ll be the more interesting command to see here, because it’s the one responsible for installing the hashicorp/aws provider for the other commands to find.

HI,

Even we are receiving the same error after upgrading the scripts from 0.14.7 to the latest 1.0.2.

terraform apply show below error

Error: Could not load plugin


│ Plugin reinitialization required. Please run “terraform init”.

│ Plugins are external binaries that Terraform uses to access and manipulate
│ resources. The configuration provided requires plugins which can’t be located,
│ don’t satisfy the version constraints, or are otherwise incompatible.

│ Terraform automatically discovers provider requirements from your
│ configuration, including providers used in child modules. To see the
│ requirements and constraints, run “terraform providers”.

│ 3 problems:

│ - failed to instantiate provider “registry.terraform.io/hashicorp/aws” to obtain schema: unknown provider “registry.terraform.io/hashicorp/aws
│ - failed to instantiate provider “registry.terraform.io/hashicorp/local” to obtain schema: unknown provider “registry.terraform.io/hashicorp/local
│ - failed to instantiate provider “registry.terraform.io/hashicorp/template” to obtain schema: unknown provider “registry.terraform.io/hashicorp/template

We tried remove the terraform provider folder and recreate using terraform init command, but the issue is same.

Below is the output of terraform init -upgrade command after we removed terraform folder.

Initializing the backend…

Successfully configured the backend “s3”! Terraform will automatically
use this backend unless the backend configuration changes.

Initializing provider plugins…

  • Finding hashicorp/aws versions matching “~> 3.27”…
  • Finding latest version of hashicorp/local…
  • Finding latest version of hashicorp/template…
  • Installing hashicorp/aws v3.49.0…
  • Installed hashicorp/aws v3.49.0 (signed by HashiCorp)
  • Installing hashicorp/local v2.1.0…
  • Installed hashicorp/local v2.1.0 (signed by HashiCorp)
  • Installing hashicorp/template v2.2.0…
  • Installed hashicorp/template v2.2.0 (signed by HashiCorp)

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running “terraform plan” to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.

Hi, I get the same error frequently in 1.0.6.

terraform init show below error

Initializing the backend...

Successfully configured the backend "s3"! Terraform will automatically
use this backend unless the backend configuration changes.

Initializing provider plugins...
- Finding latest version of hashicorp/aws...
- Installing hashicorp/aws v3.59.0...
╷
│ Error: Failed to install provider
│ 
│ Error while installing hashicorp/aws v3.59.0: read tcp
│ xxx.xxx.xxx.xxx:51354->xxx.xxx.xxx.xxx:443: read: connection reset by peer
╵

In my case, I was running terraform init consecutively to run terraform plan against multiple tfstates in a single job, and I had to install the plugin each time.
I reduced the number of installs by using TF_PLUGIN_CACHE_DIR to share the cache, and the error is no longer reproduced.

Hi @hs118505 I am running into the same issue. Did you find a workaround ?

Yes, this issue was resolved by upgrading the terraform and aws provider version to the latest.