Commands that wait on slow AWS API responses, proxy hops, or large S3 transfers can still be healthy even when the next response bytes take longer than usual to arrive. Saving a larger read timeout keeps AWS CLI from aborting those long-running reads too early, while a smaller value helps stalled sessions fail faster.
The persistent setting is cli_read_timeout in the shared AWS CLI config file. aws configure set writes the value into [default] or [profile NAME] in ~/.aws/config, and aws configure get reads that saved value back locally without contacting AWS. For a single exception, --cli-read-timeout overrides the saved profile value only for the command where it is used.
AWS documents a default socket read timeout of 60 seconds, and 0 disables the read timeout so the socket blocks indefinitely. If aws configure get cli_read_timeout prints nothing, the profile is still using that default instead of an explicitly saved value, so indefinite reads belong only in shells or automation that already have their own watchdog.
Steps to set AWS CLI read timeout:
- Check the currently saved read timeout in the target profile before changing it.
$ aws configure get cli_read_timeout
No output means the profile does not have an explicit saved value and the AWS CLI default of 60 seconds is still in effect.
- Save a new read timeout for the default profile when most commands on the workstation should use the same limit.
$ aws configure set cli_read_timeout 120
This writes
cli_read_timeout = 120
under the
[default]
section in the active shared config file.
- Read the saved value back from the default profile to confirm that the change was written.
$ aws configure get cli_read_timeout 120
This confirms the persistent profile setting rather than a one-command override.
- Save a different read timeout on a named profile when one account, job, or network path needs a different value.
$ aws configure set cli_read_timeout 300 --profile archive $ aws configure get cli_read_timeout --profile archive 300
This stores the value under
[profile archive]
and leaves the default profile unchanged.
- Inspect the shared config file when the exact profile section or stored line must be confirmed directly.
$ sed -n '1,20p' "${AWS_CONFIG_FILE:-$HOME/.aws/config}" [default] cli_read_timeout = 120 [profile archive] cli_read_timeout = 300If AWS_CONFIG_FILE is set, the command reads that override path instead of the default shared file. On Windows, the default config path is
%UserProfile%\.aws\config
.
Related: How to find the AWS CLI config file
- Override the saved value for one slow command when a longer read window is needed without changing the profile permanently.
$ aws s3 sync s3://example-archive-bucket/reports ./reports \ --profile archive \ --cli-read-timeout 900
The --cli-read-timeout flag takes precedence for that single invocation and does not rewrite the shared config file.
- Set the value to 0 only when an indefinite read is intentional and the calling environment already enforces its own timeout or watchdog.
$ aws configure set cli_read_timeout 0 --profile archive $ aws configure get cli_read_timeout --profile archive 0
A value of 0 makes socket reads block indefinitely, which can leave interactive shells and automation waiting forever on a dead or silent connection.
Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.
