How to set retry mode in AWS CLI

Retry behavior in AWS CLI determines how commands respond to throttling, transient HTTP failures, and short-lived connection errors. Saving the correct mode in the active profile keeps routine terminal work and automation from inheriting stale retry behavior from an old workstation setup or a temporary shell override.

The setting is stored as retry_mode in the shared AWS configuration file and is read per profile. aws configure set writes the value into [default] or a named [profile NAME] block, while aws configure get reads the saved value back from the config file without making an AWS API call.

Current AWS documentation recommends standard and uses it as the default mode in AWS CLI v2, while legacy keeps the older retry handler and adaptive remains experimental while adding client-side rate limiting for specialized workloads. A saved profile value can still be overridden at runtime by AWS_RETRY_MODE in the current shell, so the persistent config value and the active session behavior need to be checked separately.

Steps to set AWS CLI retry mode:

  1. Choose the retry mode that matches the workload before saving it in the profile.
    Retry mode Best fit Default total attempts Notes
    standard Daily CLI use and most automation 3 Recommended in current AWS documentation and the default for AWS CLI v2
    legacy Compatibility with older retry behavior 5 Older retry handler with narrower retry coverage
    adaptive Specialized clients that need local rate limiting as well as retries 3 Experimental mode that can delay even the first request attempt

    If max_attempts is already set in the same profile, that explicit value still controls the total attempt count regardless of the selected retry_mode.

  2. Save standard as the retry mode for the default profile.
    $ aws configure set retry_mode standard

    This writes

    retry_mode = standard

    under the

    [default]

    section in ~/.aws/config.

  3. Save a different retry mode for a named profile when one workload should not inherit the default profile behavior.
    $ aws configure set retry_mode adaptive --profile batch

    adaptive mode is experimental in current AWS documentation and is intended for specialized client designs, so keep standard as the normal choice unless client-side rate limiting is required on purpose.

  4. Read the stored value back from each updated profile to confirm the change was written to the config file.
    $ aws configure get retry_mode
    standard
    $ aws configure get retry_mode --profile batch
    adaptive

    aws configure get reads the saved config value only, which makes it useful for confirming what is on disk before runtime overrides are considered.

  5. Inspect the shared config file when the profile section or the exact persisted value must be confirmed directly.
    $ cat ~/.aws/config
    [default]
    retry_mode = standard
    [profile batch]
    retry_mode = adaptive

    retry_mode belongs in ~/.aws/config rather than ~/.aws/credentials. On Windows, the matching file is

    %UserProfile%\.aws\config

    .

  6. Check for a temporary AWS_RETRY_MODE override and clear it when the saved profile value should control command execution again.
    $ printenv AWS_RETRY_MODE
    legacy
    $ unset AWS_RETRY_MODE

    No output from

    printenv AWS_RETRY_MODE

    means no shell-level retry-mode override is active. The exported variable changes runtime behavior even though aws configure get retry_mode still reports the saved on-disk value.