Problem
When running terraform init, the command fails to load a provider plugin and returns one of the following errors:
Error: Could not load plugin ... permission deniedError: Could not load plugin ... exec format error
These errors prevent Terraform from initializing the working directory and downloading the necessary providers.
Cause
These errors typically occur for one of two reasons:
-
Incorrect Permissions: The provider binary file was downloaded but does not have execute permissions. This can happen if the working directory is on a filesystem mounted with the
noexecoption or one that does not support executable permissions (e.g., FAT32). - Architecture Mismatch: The provider binary was compiled for a different operating system or CPU architecture than the machine running Terraform (e.g., a Windows binary on a macOS machine, or an ARM64 binary on an AMD64 machine).
Solutions
Follow the solution that corresponds to the error message you received.
Solution 1: Resolve "permission denied" error
This error indicates that Terraform cannot execute the provider binary.
│ 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: fork/exec │ .terraform/providers/registry.terraform.io/hashicorp/aws/3.50.0/linux_amd │ 64/terraform-provider-aws_v3.50.0_x5: │ permission denied
1. Check Filesystem Mount Options
Confirm that your working directory's filesystem is not mounted with the noexec option. This option prevents binaries from being executed. Run the following command to check your system's mount points.
$ mount | grep noexec
If your filesystem appears in the output, you must remount it without the noexec flag or move your Terraform project to a different filesystem.
2. Verify and Set Execute Permissions
If the filesystem is mounted correctly, inspect the provider binary's permissions. The path to the binary is included in the error message.
-
Check the current permissions of the provider binary. Note that the provider name, version, OS, and architecture in the path are examples.
$ ls -l .terraform/providers/registry.terraform.io/hashicorp/aws/3.50.0/linux_amd64/
A correct, executable file will have
xin its permissions string (e.g.,-rwxr-xr-x). If it is missing, you will see a pattern like-rw-r--r--. -
If the execute permission is missing, add it using the
chmodcommand.$ chmod +x .terraform/providers/registry.terraform.io/hashicorp/aws/3.50.0/linux_amd64/terraform-provider-aws_v3.50.0_x5
Outcome
After applying the execute permission, delete the .terraform.lock.hcl file and run terraform init again. Terraform should now be able to load the provider plugin successfully.
Solution 2: Resolve "exec format error"
This error indicates that the provider binary is not compatible with your system's operating system or architecture.
│ Error: Could not load plugin │ │ Plugin reinitialization required. Please run "terraform init". │ │ ... │ │ failed to instantiate provider "example.com/example/vault" │ to obtain schema: │ fork/exec │ .terraform/providers/example.com/example/vault/0.1.0/linux_amd64/terrafor │ m-provider-vault: │ exec format error
1. Verify Provider Architecture
Ensure the provider binary matches the architecture of the machine where you are running Terraform. This is especially important for manually installed or third-party providers.
You can use the file command to inspect the binary and confirm its target OS and architecture.
For official providers, you can find binaries for all supported platforms on their release pages. For example, you can view the available architectures on the AWS provider v3.63.0 release page.
2. Re-initialize Terraform
If you have an incorrect binary, you must replace it with the correct one.
-
Delete the
.terraformdirectory and the.terraform.lock.hclfile from your working directory to remove the cached, incorrect provider.$ rm -rf .terraform .terraform.lock.hcl
- Run
terraform initagain. Terraform will download the correct provider for your platform from the Terraform Registry.
Outcome
After re-initializing, Terraform will download and install the correct provider binary, resolving the error.