How I troubleshoot when EC2 instance terminates unexpectedly

It’s a common issue in AWS environment. Your instance goes from the pending state to the terminated state without you doing anything.

Below are my 5 tips to troubleshoot this issue.

1. Check CloudTrail Logs for Termination Events

  • Go to AWS CloudTrail and filter for TerminateInstances API calls.
  • Search for who or what initiated the termination (a user, a Lambda function, or an automation process).
  • CloudTrail usually tells you when, how, and under what identity the instance was stopped.

2. Review Auto Scaling Group Settings

  • If the instance was part of an Auto Scaling group, it might’ve been terminated due to scaling policies or a health check failure.
  • Go to the EC2 console → Auto Scaling Groups → Activity History to confirm.
  • Also, check if a new instance replaced it.

3. Check for Spot Instance Interruptions or Billing Limits

  • Go to the EC2 Spot Requests page and see if there was a price surge or capacity issue.
  • For regular instances, make sure your AWS account hasn’t hit a billing threshold or service quota that triggered the termination.

4. Verify Termination Protection Settings

  • To protect the instance, make sure “termination protection” was enabled.
  • You can find this under the instance’s settings in the EC2 console.
  • Without it, anyone (or anything with permissions) can terminate the instance easily.

5. Restore from a Snapshot or AMI

  • If the instance is gone and can’t be recovered, use an Amazon Machine Image (AMI) or EBS snapshot (if available) to launch a new one.
  • This helps bring things back online quickly while you continue to investigate.
What other tips or steps would you add to this list? 

Leave a Reply

Your email address will not be published. Required fields are marked *