hashicorp/terraform · error

a network issue prevented cloud configuration; %w

Error message

a network issue prevented cloud configuration; %w

What it means

During service discovery, services.Discover(hostname) failed with a disco.ErrServiceDiscoveryNetworkRequest: Terraform could not reach the host's .well-known/terraform.json discovery endpoint. It is surfaced when setting up cloud-backed terraform test.

Source

Thrown at internal/cloud/test.go:329

		return moduletest.Pass, diags
	case tfe.TestPending:
		return moduletest.Pending, diags
	case tfe.TestSkip:
		return moduletest.Skip, diags
	default:
		panic("found unrecognized test status: " + run.TestStatus)
	}
}

// discover the TFC/E API service URL
func discoverTfeURL(hostname svchost.Hostname, services *disco.Disco) (*url.URL, error) {
	host, err := services.Discover(hostname)
	if err != nil {
		var serviceDiscoErr *disco.ErrServiceDiscoveryNetworkRequest

		switch {
		case errors.As(err, &serviceDiscoErr):
			err = fmt.Errorf("a network issue prevented cloud configuration; %w", err)
			return nil, err
		default:
			return nil, err
		}
	}

	return host.ServiceURL(tfeServiceID)
}

func (runner *TestSuiteRunner) client(addr tfaddr.Module, id tfe.RegistryModuleID) (*tfe.Client, *tfe.RegistryModule, tfdiags.Diagnostics) {
	var diags tfdiags.Diagnostics

	var client *tfe.Client
	if runner.clientOverride != nil {
		client = runner.clientOverride
	} else {
		service, err := discoverTfeURL(addr.Package.Host, runner.Services)
		if err != nil {

View on GitHub (pinned to c9def3e214)

Solutions

  1. Verify connectivity: curl https://<host>/.well-known/terraform.json.
  2. Correct the hostname and organization in the module source address.
  3. Configure HTTP(S) proxy environment variables if behind a proxy.
  4. Retry after confirming DNS resolves.

Example fix

# before: wrong host / no egress -> a network issue prevented cloud configuration
# after: fix hostname and confirm discovery endpoint reachable
curl -I https://app.terraform.io/.well-known/terraform.json
terraform test
Defensive patterns

Strategy: validation

Validate before calling

// Pre-flight: confirm the discovery endpoint is reachable
resp, err := http.Get("https://" + hostname + "/.well-known/terraform.json")
if err != nil {
    return fmt.Errorf("cannot reach discovery endpoint for %s: %w", hostname, err)
}
defer resp.Body.Close()

Type guard

func isServiceDiscoveryNetworkError(err error) bool {
    var discoErr *disco.ErrServiceDiscoveryNetworkRequest
    return errors.As(err, &discoErr)
}

Try / catch

_, err := discoverTfeURL(hostname, services)
if err != nil {
    var discoErr *disco.ErrServiceDiscoveryNetworkRequest
    if errors.As(err, &discoErr) {
        // fix connectivity/proxy/hostname, then retry
    }
}

Prevention

When it happens

Trigger: terraform test against HCP/TFE when the hostname is unreachable: DNS failure, no network, proxy/firewall blocking the discovery request, or a wrong hostname.

Common situations: Offline or air-gapped machine without connectivity, a mistyped hostname in the module source, a corporate proxy blocking discovery, or a transient DNS outage.

Related errors


AI-assisted analysis of hashicorp/terraform@c9def3e214 (2026-08-07). Data as JSON: /api/errors/60151db421ca36cb. Report an issue: GitHub.