Your Authorization Token has expired when trying to push to ECS docker repository

The Error

denied: Your Authorization Token has expired. Please run 'aws ecr get-login' to fetch a new one.

This is just for storing the command below. Every time I want to do a docker push to my ECS repo, I need get the denied error if I’m working in the wrong region. You must run the get-login command for the region your repo is in. Also, don’t forget to copy and run the command that’s returned, it does not run automatically.

The Fix

aws ecr get-login --region us-west-2

Login using the –region tag, changing the region to the region your docker repo is in.

Share this:

2 comments, add yours.

Fran

Thanks but that’s not fully useful
1) It’s best to set the region on your ~/.aws/config file:
[default]
region=REGION
output=json
2) “Also, don’t forget to copy and run the command that’s returned, it does not run automatically.” -> simply use $() around the command:
$(aws ecr get-login)

cross

here is link to the stack overflow answer for this which works as of 9/28/2021
https://stackoverflow.com/questions/41379808/authorization-token-has-expired-issue-aws-cli-on-macos-sierra

Leave a comment