Terraform: Error: reading EC2 Instance (i-0abc): couldn't find resource / 404 ResourceNotFound during refresh
A resource tracked in state no longer exists in the cloud (deleted manually) or can't be read with current credentials.
Error: reading EC2 Instance (i-0abc): couldn't find resourceError: Error reading resource: 404 Not FoundError: reading resource: ResourceNotFoundExceptionError: error reading: NotFound: Not Found status code: 404Error: reading Resource Group: ResourceGroupNotFound Meaning
Most providers remove missing resources from state automatically on refresh; some error. Check you're using the right account/region/credentials, then terraform apply -refresh-only or terraform state rm ADDRESS to forget it, or recreate it with terraform apply. Permission errors can look like "not found" for some APIs.
Common causes
- Resource deleted manually
- Wrong credentials/region (can't see it)
- Resource moved to another project/subscription
- Eventually consistent API
- Provider bug on a deleted parent
⚡ Quick fix
- Verify with the cloud CLI/console
terraform apply -refresh-onlyto reconcileterraform state rm ADDRESSto drop it if intentionally gone
Detailed fix by platform
Terraform
terraform state list | grep web && terraform state rm aws_instance.web
How to diagnose
- Exists — In the cloud?
- Identity — Right account?
- Action — Recreate or forget?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- Cannot import non-existent remote object Terraform: Error: Cannot import non-existent remote object — While attempting to import an existing object to "aws_s3_bucket.logs", the provider detected that no object exists with the given id
- Error acquiring the state lock Terraform: Error: Error acquiring the state lock — ConditionalCheckFailedException / state blob is already locked
- Error building ARM Config: obtain subscription from Azure CLI Terraform: Error: building AzureRM Client: obtaining subscription ID / Please run 'az login' to setup account
Most viewed in Terraform
- Inconsistent dependency lock file Terraform: Error: Inconsistent dependency lock file — provider x: required by this configuration but no version is selected
- Reference to undeclared resource Terraform: Error: Reference to undeclared resource / Reference to undeclared input variable
- Resource is tainted and must be replaced Terraform: # aws_instance.web is tainted, so must be replaced — -/+ destroy and then create replacement
Other ways to find it
Where this error sits
Origin: Platform & cloud. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 5 Nov 2026