aws login: stale browser cookies cause 400 Bad Request — CLI hangs until timeout with no feedback
Describe the bug
When aws login opens the browser and stale AWS session cookies are present, the signin
portal returns 400 Bad Request directly to the browser. The CLI's local callback server
(127.0.0.1:PORT) never receives a redirect, so the process hangs silently for up to
10 minutes with no feedback before failing.
Expected Behavior
When a browser session cookie is detected but the underlying session has expired, the server should redirect the browser to the login page so the user can re-authenticate and complete the OAuth flow naturally — rather than returning 400.
If redirecting to the login page is not possible, the server should communicate the failure
back through the redirect_uri with an error parameter as required by
RFC 6749 §4.1.2.1,
allowing the CLI to surface a meaningful error immediately.
Current Behavior
- CLI starts a local callback server at
http://127.0.0.1:PORT/oauth/callback - CLI opens
/v1/authorize?...&redirect_uri=http://127.0.0.1:PORT/oauth/callbackin the browser - The server detects existing browser session cookies and attempts to reuse the session
- Browser is redirected to
/v1/sessions?... - Browser is redirected to
/oauth?iam_user=true&backwards_compatible=true&... - Server returns 400 Bad Request — browser shows an error page and stops
- The
redirect_uriis never called; the CLI hangs for up to 10 minutes then raisesPendingAuthorizationExpiredErrorwith no useful message
Reproduction Steps
- Sign into the AWS Management Console in your browser (sets session cookies)
- Wait for the server-side session to expire (the browser cookies remain)
- Run
aws login - The browser opens and immediately shows a 400 error page
- The CLI prints nothing — it hangs until the 10-minute
_OVERALL_TIMEOUTinAuthCodeFetcher.get_auth_code_and_state(), then raisesPendingAuthorizationExpiredError
Possible Solution
Replace the current error-based stale cookie handling with a proper authentication redirect flow. Instead of surfacing a 400 error to the user when a stale cookie is detected, the server should transparently redirect the user through the login page so the CLI can obtain a fresh token without requiring manual intervention. Current flow (broken): stale cookie detected → try session reuse → error 400 Proposed flow: stale cookie detected → redirect to login page → user authenticates → redirect_uri called with auth code → CLI exchanges code for token
CLI version used
aws-cli/2.34.23
Environment details (OS name and version, etc.)
Python/3.14.3 Linux/6.8.0-106-generic exe/x86_64.ubuntu.24 OS: Ubuntu 24.04 Browser: Brave (Chromium-based) Region: eu-south-2
Hello @AlRos14, thank you for reaching out. I am investigating this issue and I will update back as soon as I have updates.
Hello @AlRos14! After investigating, it seems that the 400 Error is coming from the SignIn service and does not redirect to the login page. I have reached out to the SignIn team in this regard and will update you as soon as there any updates form the team.
Internal Ref: P411663187
Hi @adev-code, do we have any update regarding this issue ?
More than 2 months now and no update! When can we expect this to be worked on as it is a major headache.
One of my team members is experiencing this error now. Tried it with incognito mode and still got the same error. And regardless of browser used.
Same issue here, I've been scratching my head the whole day trying to figure out the issue. So this could be an issue on AWS team huh?
$ aws --version
aws-cli/2.35.11 Python/3.14.5 Darwin/25.2.0 exe/arm64
Same issue! Any progress now?
I am having the same issue
Having same issue
Having same issue
+1 to the issue. unable to login.
+1 Here as well.
Same here. There's no indication of why this is failing. This effectively prevents me from using the AWS CLI entirely
+1
+1 same issue - although switching to a different account might fix it for me
refer to https://repost.aws/questions/QUmrioyrpWRDGdEjs20O0tQQ/400-bad-request-when-logging-in-using-aws-cli, IAM account would require SignInLocalDevelopmentAccess policy to login.
@HernandoR
Thanks for sharing this. I’m not sure the permission itself explains the 400 Bad Request, though. I have been experiencing the same issue even with administrator permissions.
SignInLocalDevelopmentAccess is clearly required for aws login, but the failure described here appears to happen earlier in the browser-side session/OAuth flow. It may be that adding the policy coincided with the AWS session or cookies being refreshed, which then made the next attempt work.
The issue has also been open for almost three months, and so far the only update from AWS has been that it was referred internally. It would be helpful to know whether the underlying service team has identified the cause or if a fix is being worked on.
I am also having this issue. There's seriously no update after 4 months?
Same issue here. Waiting for the updates :(
Classic AWS