Why can't I start or launch my EC2 instance?

Last updated: 2021-10-08

I can't launch or start my Amazon Elastic Compute Cloud (Amazon EC2) instance. How can I troubleshoot this problem?

Short description

There are multiple reasons why you might not be able to launch or start your EC2 instance. If you don't receive an error code when attempting to start the instance, run the describe-instances command in the AWS Command Line Interface (AWS CLI). Then, specify the instance ID to view the reason for the problem. In the following example, replace MYINSTANCE with the id of the instance that you're trying to start.

Note: If you receive errors when running AWS CLI commands, make sure that you’re using the most recent version of the AWS CLI.

aws ec2 describe-instances --instance-id MYINSTANCE --output json

Check the StateReason message in the JSON response returned by the command.

In the following example, the StateReason returned is "Client.InternalError".

"StateReason": {
     "Message": "Client.InternalError: Client error on launch",
     "Code": "Client.InternalError"
   },

Resolution

The following are common errors that can prevent you from starting your instance:

InsufficientInstanceCapacity

Error message: "An error occurred (InsufficientInstanceCapacity) when calling the RunInstances operation (reached max retries: 4). We currently do not have sufficient capacity in the Availability Zone you requested." This error occurs if there isn't enough On-Demand capacity to complete your request.

For information on resolving this error, see How do I troubleshoot InsufficientInstanceCapacity errors when starting or launching an EC2 instance?

InstanceLimitExceeded

Error message: "Your quota allows for 0 more running instance(s)." This error occurs if you launched the maximum allowed instances in your Region.

For information on resolving this error, see How do I troubleshoot InstanceLimitExceeded errors when starting or launching an EC2 instance?

UnauthorizedOperation

The UnauthorizedOperation error indicates that the user attempting to launch the instance doesn't have the required permissions. For information on resolving this error, see Why am I receiving the error message "You are not authorized to perform this operation" when I try to launch an EC2 instance?

The requested configuration is currently not supported

This error is caused by the following two issues:

1.    The specified instance type isn't supported in the requested Availability Zone. Run the aws ec2 describe-instance-type-offerings command in the AWS CLI to check the availability of the instance types in specific Availability Zones. Then, launch the instance in a supported Availability Zone.

For example, use the following command to check availability of the c5.2xlarge instance type across all Availability Zones in us-east-1:

aws ec2 describe-instance-type-offerings --location-type availability-zone --filters Name=instance-type,Values=c5.2xlarge --region us-east-1

2.    The Amazon Machine Image (AMI) used to launch the instance doesn't support the selected instance type. Refer to the AMI description in the AWS Documentation before selecting the instance type or family. This issue commonly occurs when using AWS Marketplace AMIs and launching them using the AWS CLI. When launching instances from the Amazon EC2 console, unsupported instances are unavailable.

Client.InternalError

There are several reasons you might receive this error:

  • An Amazon Elastic Block Store (Amazon EBS) volume isn't correctly attached to the instance.
  • An EBS volume that's attached to the instance is in an ERROR state.
  • An encrypted EBS volume is attached to the instance. However, you don't have permissions to access the AWS Key Management Services (AWS KMS) for decryption.

For information on resolving these issues, see I'm unable to start my instance and I see Client.InternalError when running the describe-instances command. How do I fix this?

Disk full errors

Disk full errors occur when you run out of space on the instance and the audit service stops the machine as soon as it's booted.

Note: It's a best practice to back up your data by creating a snapshot of your volumes before proceeding.

Important:

These resolution steps require a stop and start of the instance. Be aware of the following:

  • Data in instance store volumes is lost when the instance is stopped. For more information, see Determine the root device type of your instance.
  • If your instance is part of an Amazon EC2 Auto Scaling group, then stopping the instance might terminate it. Instances launched with Amazon EMR, AWS CloudFormation, AWS Elastic Beanstalk might be part of an AWS Auto Scaling group. Instance termination in this scenario depends on the instance scale-in protection settings for your Auto Scaling group. If your instance is part of an Auto Scaling group, temporarily remove it from the Auto Scaling group before starting the resolution steps.
  • Stopping and starting the instance changes the public IP address of your instance. It's a best practice to use an Elastic IP address instead of a public IP address when routing external traffic to your instance.

To resolve disk full errors, do the following:

1.    Open the Amazon EC2 console.

2.    Choose Instances from the navigation pane, and then select the instance.

3.    Stop the instance.

4.    Detach the EBS root volume ( /dev/xvda or /dev/sda1) from the stopped instance.

5.    Launch a new EC2 instance in the same Availability Zone as the impaired instance. The new instance becomes your rescue instance.

6.    Attach the root volume that you detached in step 4 to the rescue instance as a secondary device.

Note: You can use different device names when attaching secondary volumes.

7.    Connect to your rescue instance using SSH.

8.    Create a mount point directory for the new volume attached to the rescue instance in step 6. In the following example, the mount point directory is /mnt/rescue.

$ sudo mkdir /mnt/rescue

9.    Mount the volume at the directory you created in step 8.

$ sudo mount /dev/xvdf /mnt/rescue

Note: The device (/dev/xvdf, in the preceding example) might be attached to the rescue instance with a different device name. Use the lsblk command to view your available disk devices along with their mount points to determine the correct device names.

10.    Increase the root volume size.

11.    Extend the partition.

12.    Run the umount command to unmount the volume.

$ sudo umount /mnt/rescue

13.    Detach the volume from the temporary instance.

14.    Attach the volume to original instance, and then start the instance to confirm that it boots successfully.

15.    Review the audit service configuration to make sure that it doesn't have the option to halt (shutdown) the machine if it runs out of space. The audit service configuration should include the following options in /etc/audit/auditd.conf on Amazon Linux and Amazon Linux 2:

max_log_file_action = ROTATE
admin_space_left_action = SUSPEND
disk_full_action = SUSPEND
disk_error_action = SUSPEND