hashicorp/terraform · error
Invalid unix socket path %q for %q: %w
Error message
Invalid unix socket path %q for %q: %w
What it means
ParseReattachProviders hit an entry whose Addr.Network is "unix" but net.ResolveUnixAddr rejected Addr.String, so no usable net.Addr could be built for the plugin handshake. The reattach config for that provider is unusable.
Source
Thrown at internal/getproviders/reattach/reattach.go:66
Pid int
Test bool
}
var m map[string]reattachConfig
err := json.Unmarshal([]byte(in), &m)
if err != nil {
return unmanagedProviders, fmt.Errorf("Invalid format for %s: %w", TF_REATTACH_PROVIDERS, err)
}
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,
}
}
}View on GitHub (pinned to c9def3e214)
Solutions
- Confirm the unix socket path exists and is writable: ls -l on the cited path.
- Regenerate TF_REATTACH_PROVIDERS from the provider's launcher so the path matches the actually-created socket.
- Switch the entry to a TCP address if unix sockets are unreliable in your CI sandbox.
Example fix
// before
"Addr": {"Network":"unix","String":""}
// after
"Addr": {"Network":"unix","String":"/tmp/plugin98765"} Defensive patterns
Strategy: validation
Validate before calling
import "net"
// Validate a unix reattach address before building the env var.
func validateUnixAddr(p, socketPath string) error {
if _, err := net.ResolveUnixAddr("unix", socketPath); err != nil {
return fmt.Errorf("invalid unix socket %q for %q: %w", socketPath, p, err)
}
if _, err := os.Stat(socketPath); socketPath != "" && err != nil {
return fmt.Errorf("socket path not accessible %q: %w", socketPath, err)
}
return nil
} Prevention
- Create the unix socket before Terraform reads TF_REATTACH_PROVIDERS.
- Prefer absolute paths under a known temp dir the provider owns.
- In CI, clean up stale socket paths each run.
When it happens
Trigger: TF_REATTACH_PROVIDERS entry with Addr.Network="unix" and an Addr.String that is not a resolvable unix socket path: empty string, a path containing a NUL byte, or (on some platforms) an abstract socket syntax the resolver rejects.
Common situations: Test harness emits a relative or templated path that was never substituted; leftover socket path from a deleted temp dir; copy-paste truncating the path; macOS /var/folders path copied onto Linux where the parent dir differs.
Related errors
- Error parsing %q as a provider address: %w
- Invalid TCP address %q for %q: %w
- Unknown address type %q for %q
- default workspace not supported You can create a new workspa
- approved using the UI or API
AI-assisted analysis of hashicorp/terraform@c9def3e214 (2026-08-07).
Data as JSON: /api/errors/3eefd94afc850387.
Report an issue: GitHub.