hashicorp / terraform

Terraform enables you to safely and predictably create, change, and improve infrastructure. It is a source-available tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned.
https://www.terraform.io/
Other
42.58k stars 9.54k forks source link

Error: Failed to query available provider packages: Client.Timeout exceeded while awaiting headers #26532

Closed snemetz closed 3 years ago

snemetz commented 4 years ago

Terraform Version

Terraform v0.13.4
Also tried 0.13.3 got same issue

Terraform Configuration Files

terraform {
  required_version = ">= 0.13"
  required_providers {
   aws = {
     source  = "hashicorp/aws"
     version = "~> 3.0"
   }
 }
}

Expected Behavior

Expected init to work

Actual Behavior

Initializing provider plugins...

Error: Failed to query available provider packages

Could not retrieve the list of available versions for provider hashicorp/aws: could not query provider registry for registry.terraform.io/hashicorp/aws: the request failed after 2 attempts, please try again later: Get "https://registry.terraform.io/v1/providers/hashicorp/aws/versions": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

Steps to Reproduce

terraform init

Additional Context

I can use curl and access the url that terraform says it can't access with no issues I've tried multiple times over 2 days and issue doesn't change. Terraform always fails, curl always succeeds Had no issues with 0.12, but 0.13 has not worked yet Terraform section was the only change made going to 0.13 This is on Mac I also tried with only the posted terraform config and still get same issue

zzxwill commented 3 years ago

I am still getting this issue with Terraform 1.0.1 on an alpine docker image.

bash-5.1# ./terraform init
2021-06-29T09:15:06.197Z [DEBUG] Adding temp file log sink: /tmp/terraform-log106468856
2021-06-29T09:15:06.197Z [INFO]  Terraform version: 1.0.1
2021-06-29T09:15:06.197Z [INFO]  Go runtime version: go1.16.4
2021-06-29T09:15:06.197Z [INFO]  CLI args: []string{"/data/terraform", "init"}
2021-06-29T09:15:06.197Z [TRACE] Stdout is a terminal of width 175
2021-06-29T09:15:06.197Z [TRACE] Stderr is a terminal of width 175
2021-06-29T09:15:06.197Z [TRACE] Stdin is a terminal
2021-06-29T09:15:06.197Z [DEBUG] Attempting to open CLI config file: /root/.terraformrc
2021-06-29T09:15:06.197Z [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2021-06-29T09:15:06.197Z [DEBUG] checking for credentials in "/root/.terraform.d/plugins"
2021-06-29T09:15:06.197Z [DEBUG] ignoring non-existing provider search directory terraform.d/plugins
2021-06-29T09:15:06.197Z [DEBUG] will search for provider plugins in /root/.terraform.d/plugins
2021-06-29T09:15:06.198Z [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/hashicorp/alicloud v1.120.0 for linux_amd64 at /root/.terraform.d/plugins/registry.terraform.io/hashicorp/alicloud/1.120.0/linux_amd64
2021-06-29T09:15:06.198Z [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/hashicorp/aws v3.36.0 for linux_amd64 at /root/.terraform.d/plugins/registry.terraform.io/hashicorp/aws/3.36.0/linux_amd64
2021-06-29T09:15:06.198Z [DEBUG] ignoring non-existing provider search directory /root/.local/share/terraform/plugins
2021-06-29T09:15:06.198Z [DEBUG] ignoring non-existing provider search directory /usr/local/share/terraform/plugins
2021-06-29T09:15:06.198Z [DEBUG] ignoring non-existing provider search directory /usr/share/terraform/plugins
2021-06-29T09:15:06.199Z [INFO]  CLI command args: []string{"init"}
Initializing modules...
2021-06-29T09:15:06.203Z [TRACE] ModuleInstaller: installing child modules for . into .terraform/modules
2021-06-29T09:15:06.204Z [DEBUG] Module installer: begin vpc
2021-06-29T09:15:06.204Z [TRACE] ModuleInstaller: vpc is not yet installed
2021-06-29T09:15:06.204Z [TRACE] ModuleInstaller: cleaning directory .terraform/modules/vpc prior to install of vpc
2021-06-29T09:15:06.204Z [TRACE] ModuleInstaller: vpc is a registry module at terraform-google-modules/network/google
2021-06-29T09:15:06.204Z [DEBUG] vpc listing available versions of terraform-google-modules/network/google at registry.terraform.io
2021-06-29T09:15:06.204Z [DEBUG] Service discovery for registry.terraform.io at https://registry.terraform.io/.well-known/terraform.json
2021-06-29T09:15:06.204Z [TRACE] HTTP client GET request to https://registry.terraform.io/.well-known/terraform.json
2021-06-29T09:15:09.201Z [ERROR] Checkpoint error: Get "https://checkpoint-api.hashicorp.com/v1/check/terraform?arch=amd64&os=linux&signature=2884c382-efd8-0c50-23d5-16d0383a2b06&version=1.0.1": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
2021-06-29T09:15:17.204Z [TRACE] modsdir: writing modules manifest to .terraform/modules/modules.json
╷
│ Error: Error accessing remote module registry
│
│ Failed to retrieve available versions for module "vpc" (main.tf:1) from registry.terraform.io: Failed to request discovery document: Get
│ "https://registry.terraform.io/.well-known/terraform.json": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers).
╵

╷
│ Error: Error accessing remote module registry
│
│ Failed to retrieve available versions for module "vpc" (main.tf:1) from registry.terraform.io: Failed to request discovery document: Get
│ "https://registry.terraform.io/.well-known/terraform.json": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers).
╵

bash-5.1# curl https://checkpoint-api.hashicorp.com/v1/check/terraform?arch=amd64&os=linux&signature=6935a4be-5f95-e966-58da-a1fe8d135790&version=0.14.10
[1] 505
[2] 506
[3] 507
[2]-  Done                    os=linux
bash-5.1# {"product":"terraform","current_version":"1.0.1","current_release":1624550981,"current_download_url":"https://releases.hashicorp.com/terraform/1.0.1/","current_changelog_url":"https://github.com/hashicorp/terraform/blob/v1.0.1/CHANGELOG.md","project_website":"https://www.terraform.io","alerts":[]}
[1]-  Done                    curl https://checkpoint-api.hashicorp.com/v1/check/terraform?arch=amd64
[3]+  Done                    signature=6935a4be-5f95-e966-58da-a1fe8d135790
kindacoder commented 3 years ago

The issue is with dns on your mac. Open your network preferences and go to DNS servers listing tab and delete all the ip addresses there. the issue will be fixed. Took me 2 days to figure it out. Screenshot 2021-06-30 at 12 29 35 AM

raoim commented 3 years ago

Yeah setting DNS to 8.8.8.8 resolved my issues https://www.support.com/how-to/how-to-change-dns-settings-on-a-mac-10189

github-actions[bot] commented 3 years ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.