FG
☁️ Cloud & DevOps

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

Freshabout 21 hours ago
Mar 14, 20260 views
Confidence Score62%
62%

Problem

Terraform Version [code block] Terraform Configuration Files [code block] Expected Behavior Expected init to work Actual Behavior Initializing provider plugins... - Finding hashicorp/aws versions matching "~> 3.0"... 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

Error Output

Error: Failed to query available provider packages

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Increase Terraform Client Timeout for Provider Queries

Medium Risk

The error occurs due to a timeout while Terraform attempts to query the provider registry for available versions. This can happen if the network connection is slow or if the registry is temporarily unresponsive. Since curl can access the URL without issues, it indicates that the problem lies within Terraform's configuration or network settings rather than the registry itself.

Awaiting Verification

Be the first to verify this fix

  1. 1

    Set HTTP Timeout in Terraform Configuration

    Increase the HTTP timeout settings in the Terraform configuration to allow more time for the provider query to complete.

    hcl
    terraform { backend "s3" {} } provider "aws" { version = "~> 3.0" }
  2. 2

    Set Environment Variable for HTTP Timeout

    Set the `TF_HTTP_TIMEOUT` environment variable to a higher value (e.g., 300 seconds) to extend the timeout for HTTP requests made by Terraform.

    bash
    export TF_HTTP_TIMEOUT=300
  3. 3

    Check Network Configuration

    Ensure that there are no firewall rules or proxy settings that might be interfering with Terraform's ability to connect to the provider registry.

    bash
    curl -I https://registry.terraform.io/v1/providers/hashicorp/aws/versions
  4. 4

    Upgrade Terraform to Latest Version

    If the issue persists, consider upgrading to the latest version of Terraform, as there may be bug fixes or improvements related to provider queries.

    bash
    brew upgrade terraform
  5. 5

    Retry Terraform Init

    After making the above changes, retry the `terraform init` command to see if the issue is resolved.

    bash
    terraform init

Validation

Confirm that the `terraform init` command completes successfully without any timeout errors. You should see the message indicating that the provider plugins have been successfully initialized.

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

terraformiacawsbugnewwaiting-for-reproduction