hashicorp/terraform · error

Unknown address type %q for %q

Error message

Unknown address type %q for %q

What it means

ParseReattachProviders only understands Addr.Network values of "unix" and "tcp". Any other value falls through the switch default, so the address cannot be turned into a net.Addr and reattach setup fails.

Source

Thrown at internal/getproviders/reattach/reattach.go:74

		for p, c := range m {
			a, diags := addrs.ParseProviderSourceString(p)
			if diags.HasErrors() {
				return unmanagedProviders, fmt.Errorf("Error parsing %q as a provider address: %w", a, diags.Err())
			}
			var addr net.Addr
			switch c.Addr.Network {
			case "unix":
				addr, err = net.ResolveUnixAddr("unix", c.Addr.String)
				if err != nil {
					return unmanagedProviders, fmt.Errorf("Invalid unix socket path %q for %q: %w", c.Addr.String, p, err)
				}
			case "tcp":
				addr, err = net.ResolveTCPAddr("tcp", c.Addr.String)
				if err != nil {
					return unmanagedProviders, fmt.Errorf("Invalid TCP address %q for %q: %w", c.Addr.String, p, err)
				}
			default:
				return unmanagedProviders, fmt.Errorf("Unknown address type %q for %q", c.Addr.Network, p)
			}
			unmanagedProviders[a] = &plugin.ReattachConfig{
				Protocol:        plugin.Protocol(c.Protocol),
				ProtocolVersion: c.ProtocolVersion,
				Pid:             c.Pid,
				Test:            c.Test,
				Addr:            addr,
			}
		}
	}
	return unmanagedProviders, nil
}

// IsProviderReattached determines if a given provider is being supplied to Terraform via the TF_REATTACH_PROVIDERS
// environment variable.
//
// Calling code is expected to pass in a provider address and the value of os.Getenv("TF_REATTACH_PROVIDERS")
func IsProviderReattached(provider tfaddr.Provider, in string) (bool, error) {

View on GitHub (pinned to c9def3e214)

Solutions

  1. Set Addr.Network to exactly "unix" or "tcp" (case-sensitive).
  2. If using a unix socket use "unix" and put the path in Addr.String; if TCP use "tcp" and host:port in Addr.String.
  3. Regenerate the JSON from the canonical provider launcher rather than hand-authoring.

Example fix

// before
"Addr": {"Network":"grpc","String":"127.0.0.1:12345"}
// after
"Addr": {"Network":"tcp","String":"127.0.0.1:12345"}
Defensive patterns

Strategy: validation

Validate before calling

// Validate the reattach Addr.Network before serializing TF_REATTACH_PROVIDERS.
func validateNetwork(network string) error {
    switch network {
    case "unix", "tcp":
        return nil
    default:
        return fmt.Errorf("unsupported Addr.Network %q: must be unix or tcp", network)
    }
}

Prevention

When it happens

Trigger: TF_REATTACH_PROVIDERS entry whose Addr.Network is neither "unix" nor "tcp" — e.g. "grpc", "http", "unix-socket", a typo like "TCp", or an empty string.

Common situations: Schema misunderstanding (user thinks Network should be the protocol); tooling that emits "grpc" because Protocol is grpc; case mismatch; missing Network field yielding empty string.

Related errors


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