How to fix Error: Timeout while waiting for state in Terraform

TerraformINTERMEDIATEMEDIUMUpdated Dec 30, 2025· 200 views

The "Timeout while waiting for state" error occurs when Terraform cannot detect that a resource has reached its desired state within the configured timeout period. This typically indicates either a slow-running operation, resource constraints in your cloud provider, or network connectivity issues.

Quick fix

Fixes Error: Timeout while waiting for state

Error: timeout while waiting for state to become 'running' (timeout: 5m0s)
  on main.tf line 12, in resource "aws_instance" "example":
  12:   resource "aws_instance" "example" {
  1. Identify the specific resource causing the timeout
  2. Check cloud provider console for resource status
  3. Increase the timeout for the resource
  4. Enable Terraform debug logging to see polling details
terraform — error
Error: timeout while waiting for state to become 'running' (timeout: 5m0s)
on main.tf line 12, in resource "aws_instance" "example":
12: resource "aws_instance" "example" {
Error: Timeout while waiting for state

What this error means

Terraform manages resources by monitoring their state as they transition from one status to another. When creating, updating, or deleting resources, Terraform polls the cloud provider's API to check if the resource has reached the desired state (e.g., "running" for an EC2 instance, "available" for a database). The timeout error occurs when Terraform has been polling for the configured duration (default varies by resource, typically 5-30 minutes) without the resource reaching its desired state. This doesn't necessarily mean the operation failed—it may still be in progress, but exceeded Terraform's patience.

Typical symptoms

  • Terraform apply fails with "timeout while waiting for state" message
  • Error includes the expected state (e.g., "waiting for state to become 'running'") and the actual timeout duration
  • Resource may or may not exist in your cloud provider
  • Problem occurs consistently when provisioning specific resource types
  • Large batch operations (30+ instances) more likely to timeout
  • Terraform becomes unresponsive during the polling phase

Common causes

  1. Cloud provider is experiencing high load or has insufficient capacity in your availability zone
  2. Resource provisioning genuinely takes longer than Terraform's default timeout
  3. Network latency or API rate limiting slowing down state checks
  4. Misconfigured resource settings causing provisioning to hang
  5. Cloud provider service degradation or maintenance
  6. Resource dependencies not properly specified causing ordering issues
  7. Insufficient quotas or limits reached in your cloud account

How to fix "Error: Timeout while waiting for state"

1Identify the specific resource causing the timeout

Look at the Terraform error message to see which resource and state transition timed out:

bash
Error: timeout while waiting for state to become 'running' (timeout: 5m0s)
  on main.tf line 12, in resource "aws_instance" "example":
  12:   resource "aws_instance" "example" {

This tells you exactly what to investigate in your cloud provider's console.

2Check cloud provider console for resource status

Log into your cloud provider (AWS, GCP, Azure, etc.) and verify the resource status:

AWS: Check EC2 dashboard for instance status, RDS for database status
GCP: Check Compute Engine or Cloud SQL dashboards
Azure: Check Virtual Machines or Database blade

Determine if the resource is still provisioning, stuck, or if the operation actually completed.

3Increase the timeout for the resource

Add or modify the timeouts block for the resource:

hcl
resource "aws_instance" "example" {
  ami           = "ami-0c55b159cbfafe1f0"
  instance_type = "t2.micro"

  timeouts {
    create = "30m"
    delete = "10m"
    update = "20m"
  }
}

resource "aws_db_instance" "example" {
  allocated_storage = 20
  engine            = "mysql"
  
  timeouts {
    create = "60m"
    update = "80m"
    delete = "40m"
  }
}

Set the timeout based on your resource type—databases and complex resources need longer timeouts.

4Enable Terraform debug logging to see polling details

Run Terraform with debug logging to see what states it's checking:

bash
TF_LOG=DEBUG terraform apply

This shows the actual API calls and state transitions. Look for patterns in what state Terraform is stuck waiting for and how frequently the provider is polling.

5Check for cloud provider service issues

Visit your cloud provider's status page:

- AWS: https://status.aws.amazon.com/
- GCP: https://status.cloud.google.com/
- Azure: https://status.azure.com/
- Terraform: https://status.hashicorp.com/

Look for any degradation in the region or service you're using. If there's an outage, wait for it to resolve.

6Verify resource dependencies and ordering

Ensure all dependencies are properly declared:

hcl
resource "aws_security_group" "example" {
  name = "example"
}

resource "aws_instance" "example" {
  ami                    = "ami-0c55b159cbfafe1f0"
  instance_type         = "t2.micro"
  vpc_security_group_ids = [aws_security_group.example.id]  # Explicit dependency
}

Without proper dependencies, resources may be created out of order, causing the instance to wait for the security group.

7Check cloud account quotas and limits

Verify you haven't hit service limits:

bash
# AWS - Check service quotas
aws service-quotas list-service-quotas --service-code ec2 --region us-east-1

# Check current usage
aws ec2 describe-account-attributes --region us-east-1

Common limits:
- EC2 instances per region (default 20)
- Database instances per account (default 40)
- Load balancers per region (default 20)

Request quota increases if needed.

8Check availability zone capacity

When Terraform times out on instance creation, it often means the AZ has no capacity for that instance type:

bash
# AWS - Check available capacity
aws ec2 describe-spot-price-history \
  --instance-types t2.micro \
  --region us-east-1 \
  --start-time $(date -u +%Y-%m-%dT%H:%M:%S) \
  --product-descriptions "Linux/UNIX"

Try using a different instance type or availability zone:

hcl
resource "aws_instance" "example" {
  ami               = "ami-0c55b159cbfafe1f0"
  instance_type     = "t2.small"  # Try different type
  availability_zone = "us-east-1b"  # Try different AZ
}
9Retry the operation

After investigating and fixing the root cause, retry:

bash
# First, check Terraform's state
terraform state list
terraform state show aws_instance.example

# If the resource exists but is still provisioning, just retry apply
terraform apply

# If you need to force recreation
terraform taint aws_instance.example
terraform apply

Advanced notes

Provider-Specific Timeouts:
- AWS: Database creation can take 5-15 minutes. RDS Multi-AZ adds significant time.
- GCP: Firewall rules propagation can take 1-2 minutes. VM creation is usually fast.
- Azure: Resource group deployment timeouts are independent of individual resource timeouts.
- Terraform Cloud/Enterprise: Applies run in remote environments; network latency increases timeout risk.

For Large Batch Operations:
When provisioning 30+ instances simultaneously, cloud providers often rate-limit or throttle. Solutions:
1. Use count or for_each with increased timeouts
2. Batch operations in waves (create 10, wait, create next 10)
3. Use Terraform's -parallelism=n flag to reduce concurrent requests

Auto-Scaling Timeouts:
When using auto-scaling groups, set proper health check grace periods:

hcl
resource "aws_autoscaling_group" "example" {
  health_check_grace_period = 300  # Give instances 5 minutes to start
  health_check_type         = "ELB"
}

State Lock Considerations:
If Terraform times out, it may not properly release the state lock. Use terraform force-unlock with caution if needed.

Frequently asked questions

What does "Error: Timeout while waiting for state" mean?
Terraform manages resources by monitoring their state as they transition from one status to another. , "running" for an EC2 instance, "available" for a database). The timeout error occurs when Terraform has been polling for the configured duration (default varies by resource, typically 5-30 minutes) without the resource reaching its desired state.
How do I fix "Error: Timeout while waiting for state"?
The "Timeout while waiting for state" error occurs when Terraform cannot detect that a resource has reached its desired state within the configured timeout period. This typically indicates either a slow-running operation, resource constraints in your cloud provider, or network connectivity issues.
What causes "Error: Timeout while waiting for state"?
Cloud provider is experiencing high load or has insufficient capacity in your availability zone Resource provisioning genuinely takes longer than Terraform's default timeout Network latency or API rate limiting slowing down state checks
Is the "Error: Timeout while waiting for state" error serious?
It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading