Error: Failed to install provider

I am following this tutorial:

and went execute terraform init give me this error.

Initializing the backend...

Initializing provider plugins...
- Finding hashicorp/aws versions matching "~> 2.70"...

Error: Failed to query available provider packages

Could not retrieve the list of available versions for provider hashicorp/aws:
could not connect to Failed to request discovery
document: Get "":
net/http: request canceled while waiting for connection (Client.Timeout
exceeded while awaiting headers)

This is the code:

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 2.70"

provider "aws" {
  profile = "default"
  region  = "us-west-2"

Hi @joaopixeles,

Unfortunately it seems like Terraform on your system was unable to connect to the Terraform registry in order to see which versions of hashicorp/aws are available, and so the installation failed. This sort of problem is not easy to diagnose remotely because I can’t see any details about your internet connection, what restrictions might be in place on your local network, etc.

If you are unable to reach the registry but you can reach the provider releases index directly, an alternative way to install the provider would be to manually download the version Terraform would’ve selected automatically (at the time of writing that would be v2.70.0) and extract it to one of the directories Terraform searches for local provider “mirrors”.

For example, if you are using Linux on an x64/AMD64 processor then you could extract the linux_amd64 release zip file into the following directory:


terraform init should then find that file and use the local directory instead of accessing the remote Terraform Registry.

With that said, this manual installation method means you won’t be able to automatically upgrade to later versions of the provider, so I’d still recommend trying to understand what setting on your computer or local network is causing Terraform to be unable to connect to If you do later find a way to make that work, you can remove the ~/.local/share/terraform/plugins directory to restore Terraform’s default behavior of accessing the remote registry for direct installation.