What's Actually Happening

When you stop an EC2 instance, AWS sends an ACPI shutdown signal to the guest OS. The instance is supposed to gracefully shut down all processes and transition to the 'stopped' state. But sometimes the instance gets stuck at 'stopping'β€”the shutdown process never completes, and the instance becomes unresponsive.

The Error You'll See

In the AWS Console:

bash
Instance state: stopping
(remains in this state for 10+ minutes)

Via AWS CLI:

bash
$ aws ec2 describe-instances --instance-ids i-1234567890abcdef0 --query 'Reservations[*].Instances[*].State.Name'
"stopping"

The instance remains in 'stopping' state indefinitely instead of transitioning to 'stopped'.

Why This Happens

  1. 1.Stuck shutdown process - A process inside the instance won't terminate (D-state zombie process)
  2. 2.Instance store I/O - Instance is flushing data to instance store volumes during shutdown
  3. 3.Underlying host issue - Hardware problem on the physical host
  4. 4.ENI detachment timeout - Network interface taking too long to detach
  5. 5.Hypervisor communication failure - Communication between instance and hypervisor is broken

Step 1: Wait and Check Duration

First, verify how long the instance has been stuck:

bash
# Check instance state transitions
aws ec2 describe-instances --instance-ids i-1234567890abcdef0 \
  --query 'Reservations[*].Instances[*].StateTransitionReason'

Normal shutdown can take up to 10-15 minutes for large instances with lots of memory. If it's been longer, proceed with force stop.

Step 2: Force Stop the Instance

If waiting doesn't resolve the issue, force stop:

bash
aws ec2 stop-instances --instance-ids i-1234567890abcdef0 --force

The --force flag bypasses the graceful shutdown and immediately terminates the instance.

Step 3: Check Console Output

If the instance has console output, check for clues:

bash
aws ec2 get-console-output --instance-id i-1234567890abcdef0 --output text

Look for: - Kernel panic messages - Stuck processes during shutdown - Filesystem errors - ACPI-related errors

Step 4: Investigate Root Cause After Force Stop

Once the instance is stopped, before starting it again:

bash
# Check instance attributes
aws ec2 describe-instance-attribute --instance-id i-1234567890abcdef0 --attribute instanceInitiatedShutdownBehavior

If the instance uses instance store volumes, the data is lost after force stop. Consider switching to EBS-only instance types.

Step 5: Detach and Reattach ENI (If Needed)

If network interface issues are suspected:

```bash # List ENIs attached to instance aws ec2 describe-network-interfaces --filters Name=attachment.instance-id,Values=i-1234567890abcdef0

# Create a new ENI to use if the primary is stuck aws ec2 create-network-interface --subnet-id subnet-12345 --description "Replacement ENI" ```

Step 6: Check for Underlying Host Issues

If this happens repeatedly on the same instance:

bash
# Check if instance is on a problematic host
aws ec2 describe-instances --instance-ids i-1234567890abcdef0 \
  --query 'Reservations[*].Instances[*].Placement.HostId'

Consider requesting an instance migration or stopping/starting to move to a new host.

Prevent This Issue

  1. 1.Use EBS-only instance types - Avoid instance store volumes which can cause shutdown delays
  2. 2.Set up proper shutdown scripts - Ensure applications respond to SIGTERM within reasonable time
  3. 3.Monitor shutdown duration - Set CloudWatch alarms for instances stuck in stopping state
  4. 4.Use lifecycle hooks - For Auto Scaling groups, allow proper shutdown time

Verify the Fix

```bash # After force stop, verify instance state aws ec2 describe-instances --instance-ids i-1234567890abcdef0 \ --query 'Reservations[*].Instances[*].State.Name'

# Should return: "stopped" ```

  • [Fix AWS EC2 Instance Not Responding](/articles/fix-aws-ec2-instance-not-responding)
  • [Fix AWS EC2 Status Check Failed](/articles/fix-aws-ec2-status-check-failed)
  • [Fix AWS EC2 EBS Volume Stuck Attaching](/articles/fix-aws-ec2-ebs-volume-stuck-attaching)