hashicorp/terraform · error
timeout - last error: %v
Error message
timeout - last error: %v
What it means
Same Retry loop as 777, but the context hit its deadline (context.DeadlineExceeded) at communicator.go:165. The last retryable error is included so you can see why retries kept failing. This is governed by the provisioner/connection timeout.
Source
Thrown at internal/communicator/communicator.go:166
// Wait for completion
select {
case <-ctx.Done():
case <-doneCh:
}
var lastErr error
// Check if we got an error executing
if ev, ok := errVal.Load().(errWrap); ok {
lastErr = ev.E
}
// Check if we have a context error to check if we're interrupted or timeout
switch ctx.Err() {
case context.Canceled:
return fmt.Errorf("interrupted - last error: %v", lastErr)
case context.DeadlineExceeded:
return fmt.Errorf("timeout - last error: %v", lastErr)
}
if lastErr != nil {
return lastErr
}
return nil
}
View on GitHub (pinned to c9def3e214)
Solutions
- Raise the 'timeout' in the connection block (e.g. timeout = "10m").
- Verify host reachability, open ports, and firewall/security-group rules.
- Address the appended 'last error' (auth, network, DNS) so retries succeed before the deadline.
Example fix
// before
connection {
type = "ssh"
user = "ubuntu"
host = aws_instance.web.public_ip
timeout = "30s"
}
Error: timeout - last error: dial tcp ...: i/o timeout
// after
connection {
type = "ssh"
user = "ubuntu"
host = aws_instance.web.public_ip
timeout = "10m"
} Defensive patterns
Strategy: try-catch
Validate before calling
// Size the timeout to the worst-case remote op, not the happy path. timeout := 5 * time.Minute // raise as needed for slow hosts ctx, cancel := context.WithTimeout(parentCtx, timeout) defer cancel()
Type guard
null
Try / catch
err := communicator.Retry(ctx, func() error { return c.Connect(o) })
if err != nil && errors.Is(ctx.Err(), context.DeadlineExceeded) {
// distinguish 'timeout' from a hard auth failure and guide the user
} Prevention
- Set a generous connection/command timeout for slow or ephemeral hosts.
- Pre-flight check host reachability (port open, security groups) before provisioning.
- Address the underlying retryable error so retries succeed before the deadline.
When it happens
Trigger: The retry context deadline elapses before f succeeds — the provisioner 'timeout' argument or the command timeout was exceeded while the remote op kept failing.
Common situations: Slow or unreachable remote host; flaky network; long-running remote command exceeding the configured timeout; sshd slow to start on a freshly-booted instance.
Understand the failure class
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
- interrupted - last error: %v
- operation timed out
- Cannot set both 'source' and 'content'
- Must provide one of 'source' or 'content'
- source and content cannot both be null
AI-assisted analysis of hashicorp/terraform@c9def3e214 (2026-08-07).
Data as JSON: /api/errors/2f37bd5e2a272004.
Report an issue: GitHub.