Problem: AWS Lightsail Instance is in 'stopping' State and Cannot Be Started


Problem: AWS Lightsail Instance is in 'stopping' State and Cannot Be Started

Bash
$ aws lightsail start-instance \
    --instance-name "WebServer"

An error occurred (ServiceException) when calling the StartInstance operation:
Instance is in 'stopping' state and cannot be started.

Issue:

Your AWS Lightsail instance is stuck in the "stopping" state, and AWS will not allow you to restart it. This typically happens due to:

  • Corrupt System Process – The instance failed to shut down cleanly and is now frozen.
  • AWS Service Issue – Sometimes, AWS has backend delays in stopping instances.
  • CPU/Memory Overload – The instance was under heavy load before shutdown and got stuck.
  • Underlying Hardware Failure – AWS may have detected a problem with the physical host.

Fix: Restart If Possible, Force Stop If Not, and Recover If Necessary

Bash
# Step 1: Check the current state of the instance
$ aws lightsail get-instances \
    --query "instances.{Name:name, State:state.name}" \
    --output table

# Step 1 Output:
-------------------------------
|        GetInstances         |
-------------------------------
|  Name         |  State      |
-------------------------------
|  WebServer    |  Stopping   |
-------------------------------

# If the instance is "stopping" or "stopped," attempt to start it
$ aws lightsail start-instance \
    --instance-name "WebServer"

# Step 1.1: Verify if the instance successfully started
$ aws lightsail get-instances \
    --query "instances.{Name:name, State:state.name}" \
    --output table

# Step 1.1 Output:
-------------------------------
|        GetInstances         |
-------------------------------
|  Name         |  State      |
-------------------------------
|  WebServer    |  Running    |
-------------------------------

# If the instance is now "Running," the issue is resolved, 
# and no further steps are needed.

# If the instance is still "Stopping" or does not start, move to Step 2.

# Step 2: If the instance is still "stopping," try to force stop it
$ aws lightsail stop-instance \
    --instance-name "WebServer"

# Step 2.1: If the instance remains stuck, try a forced reboot
$ aws lightsail reboot-instance \
    --instance-name "WebServer"

# Step 3: If rebooting does not work, create a snapshot (backup)
$ aws lightsail create-instance-snapshot \
    --instance-snapshot-name "WebServer-Snapshot" \
    --instance-name "WebServer"

# Step 4: Deploy a new instance from the snapshot
$ aws lightsail create-instances \
    --instance-names "WebServer-Recovered" \
    --availability-zone "us-east-1a" \
    --blueprint-id "ubuntu_22_04" \
    --bundle-id "nano_3_0" \
    --source-instance-id "WebServer-Snapshot"

# Step 5: Verify the new instance is running
$ aws lightsail get-instances \
    --query "instances.{Name:name, State:state.name}" \
    --output table

# Step 5 Output:
-----------------------------------
|        GetInstances             |
-----------------------------------
|  Name                |  State   |
-----------------------------------
|  WebServer-Recovered |  Stopped |
-----------------------------------

# If the new instance is still "stopped" or fails to boot, 
# proceed to Step 5.1

# Step 5.1: Check AWS instance health status
$ aws lightsail get-instance-metric-data \
    --instance-name "WebServer-Recovered" \
    --metric-name StatusCheckFailed \
    --period 60 \
    --statistics Maximum \
    --unit Count

# Step 5.1 Expected Output:
{
    "datapoints": [
        {
            "timestamp": "2025-02-10T12:00:00Z",
            "maximum": 1.0,
            "unit": "Count"
        }
    ],
    "label": "StatusCheckFailed"
}

# Interpretation:
# - If "maximum": 1.0 or higher → AWS detected a failure
#   (hardware or OS-level issue).
# - If "maximum": 0.0 → The instance passed AWS health checks, 
#   but other OS issues may exist.

# Step 5.2: If AWS detected failures, manually review instance logs:
$ aws lightsail get-instance-snapshot \
    --instance-snapshot-name "WebServer-Snapshot" \
    --query "instanceSnapshot.state"

# If the snapshot is corrupted, restore from an older snapshot or 
# manually create a new instance.
$ aws lightsail create-instances \
    --instance-names "WebServer-Recovered-2" \
    --availability-zone "us-east-1a" \
    --blueprint-id "ubuntu_22_04" \
    --bundle-id "nano_3_0" \
    --source-instance-id "Older-Snapshot"

# Step 5.3: If all else fails, manually create a fresh instance 
# and migrate data.
$ aws lightsail create-instances \
    --instance-names "Fresh-Instance" \
    --availability-zone "us-east-1a" \
    --blueprint-id "ubuntu_22_04" \
    --bundle-id "nano_3_0"

# Step 6: If the new instance works, delete the old stuck instance.
$ aws lightsail delete-instance \
    --instance-name "WebServer"

Need AWS Expertise?

If you're looking for guidance on Amazon Lightsail or any cloud challenges, feel free to reach out! We'd love to help you tackle your Lightsail projects. 🚀

Email us at: info@pacificw.com


Image: Gemini

Comments

Popular posts from this blog

The New ChatGPT Reason Feature: What It Is and Why You Should Use It

Raspberry Pi Connect vs. RealVNC: A Comprehensive Comparison

The Reasoning Chain in DeepSeek R1: A Glimpse into AI’s Thought Process