AWS
ServiceUnavailable - Service Unavailable
Hitting a **ServiceUnavailable** error means the AWS service is temporarily down or overloaded—this is a server-side issue (5xx) that usually resolves with retries. This server-side error happens when AWS services are experiencing outages, maintenance, or capacity issues. Most common during AWS service outages, but also appears when services are in maintenance mode, regions are experiencing issues, services are overloaded, or temporary capacity constraints occur.
#Common Causes
- →Identity: IAM service temporarily unavailable. Service Control Policy (SCP) service down. Account-level service restrictions.
- →Network: VPC endpoint service unavailable. Regional service outage. Cross-region service issues.
- →Limits: Service temporarily down for maintenance. Service overloaded (too many requests). Regional capacity exhausted. Temporary outage (check AWS status).
✓Solutions
- 1Step 1: Diagnose - Check AWS Service Health Dashboard: Visit https://status.aws.amazon.com/. Check specific service status. Review recent incidents. Check if issue is known.
- 2Step 2: Diagnose - Check CloudWatch service metrics: aws cloudwatch get-metric-statistics --namespace AWS/SERVICE --metric-name ServiceErrors --start-time TIME --end-time TIME --period 300 --statistics Sum. Monitor service availability.
- 3Step 3: Diagnose - Try different region: If service is regional, try another region: aws ec2 describe-instances --region us-west-2. Some regions may be unaffected.
- 4Step 4: Fix - Implement exponential backoff: Retry with delays: 1s, 2s, 4s, 8s, 16s. Use AWS SDK automatic retries. Add jitter to prevent thundering herd. Max retries: 5-10 attempts.
- 5Step 5: Fix - Wait and retry: If maintenance window, wait for completion. If overloaded, reduce request rate. If persistent, contact AWS Support. Monitor AWS status page for updates.
</>Code Examples
Check AWS Service Health and Status
1#!/bin/bash
2# Check AWS Service Health Dashboard
3echo "=== AWS Service Health ==="
4echo "Visit: https://status.aws.amazon.com/"
5echo "Or check programmatically via AWS Support API"
6
7# Check CloudWatch for service errors
8SERVICE="dynamodb" # Replace with your service
9REGION="us-east-1"
10echo "\n=== Checking ${SERVICE} Service Errors ==="
11aws cloudwatch get-metric-statistics \
12 --namespace AWS/${SERVICE} \
13 --metric-name ServiceErrors \
14 --dimensions Name=ServiceName,Value=${SERVICE} \
15 --start-time $(date -u -d '1 hour ago' +%Y-%m-%dT%H:%M:%S) \
16 --end-time $(date -u +%Y-%m-%dT%H:%M:%S) \
17 --period 300 \
18 --statistics Sum \
19 --region ${REGION} \
20 --output tableRetry with Exponential Backoff
1#!/bin/bash
2# Function to retry AWS CLI commands with exponential backoff
3retry_with_backoff() {
4 local max_retries=5
5 local attempt=0
6 local delay=1
7
8 while [ $attempt -lt ${max_retries} ]; do
9 if "$@"; then
10 return 0
11 fi
12
13 local exit_code=$?
14 # Check if error is ServiceUnavailable (503) or similar
15 if [ $exit_code -ne 0 ]; then
16 attempt=$((attempt + 1))
17 if [ $attempt -lt ${max_retries} ]; then
18 # Exponential backoff with jitter
19 delay=$((2 ** attempt + RANDOM % 1000 / 1000))
20 echo "Service unavailable, retrying in ${delay}s (attempt ${attempt}/${max_retries})..."
21 sleep ${delay}
22 continue
23 fi
24 fi
25 return $exit_code
26 done
27
28 return 1
29}
30
31# Example usage
32echo "=== Retrying DynamoDB PutItem ==="
33retry_with_backoff aws dynamodb put-item \
34 --table-name MyTable \
35 --item '{"id":{"S":"123"},"data":{"S":"value"}}' \
36 --output jsonTry Different Regions if Service Unavailable
1#!/bin/bash
2# Try service in different regions
3REGIONS=("us-east-1" "us-west-2" "eu-west-1")
4
5echo "=== Trying Service in Different Regions ==="
6for REGION in "${REGIONS[@]}"; do
7 echo "\nTrying region: ${REGION}"
8
9 # Example: Try DynamoDB in different region
10 aws dynamodb list-tables --region ${REGION} 2>&1 | head -3
11
12 if [ $? -eq 0 ]; then
13 echo "✓ Service available in ${REGION}"
14 break
15 else
16 echo "✗ Service unavailable in ${REGION}"
17 fi
18done↗Related Errors
Provider Information
This error code is specific to AWS services. For more information, refer to the official AWS documentation.