Skip to content
Control Plane Labs

561 Unauthorized (AWS ALB)

Server error response defined by docs.aws.amazon.com.

Written and maintained by Ben Ennis

Last reviewed November 9, 2026 · How we verify this

Common causes at a glance

  • A wrong client ID or secret in the authenticate action
  • Redirect URI not registered at the IdP
  • The IdP denying the user or rejecting a reused authorization code
  • Token or user info endpoints returning non-2xx responses

Reproduce it

curl -si https://app.example.com/ -b "$ALB_SESSION_COOKIE"

What 561 Unauthorized (AWS ALB) means

ALB listener rules can run an authenticate-oidc or authenticate-cognito action before forwarding a request, as described in the user authentication guide. The load balancer handles the OIDC flow itself: it redirects to the IdP, exchanges the code at the token endpoint, and calls the user info endpoint. When the IdP answers one of those steps with an error, the ALB stops and returns 561. Your target never sees the request, so application logs stay empty.

There is no RFC

AWS defines 561 in its ALB troubleshooting guide: the IdP returned an error code while authenticating the user, and you should check the access logs for the related error reason code. The access log reference lists those reasons in the error_reason field, including AuthInvalidGrantError, AuthInvalidIdToken, AuthTokenEpRequestFailed, and AuthUserinfoEpRequestFailed. CloudWatch splits them into ELBAuthFailure and ELBAuthError: the first counts denials and reused authorization codes, and the second counts misconfiguration and IdP connectivity problems.

What actually causes it

Separate the two metrics before changing anything. A rise in ELBAuthError after a deploy or secret rotation usually means the action’s configuration no longer matches the IdP: a rotated client secret, a changed issuer URL, or a missing redirect URI (https://<host>/oauth2/idpresponse). ELBAuthFailure is more often user-specific, such as an account the IdP refuses or a browser replaying an old callback URL with a used code.

How to debug it

Read error_reason for the 561 lines. It’s the quoted field after the TLS and target fields, so grep for it:

zcat *.log.gz | awk '$9 == 561' | grep -oE '"Auth[A-Za-z]+"' | sort | uniq -c

Then test the IdP endpoints from outside AWS with the same client credentials.

Working examples

curl

# Check the IdP's discovery document the action points at.
curl -s https://idp.example.com/.well-known/openid-configuration | jq '{issuer, token_endpoint, userinfo_endpoint}'

# Inspect the listener rule's authenticate action.
aws elbv2 describe-rules --listener-arn "$LISTENER_ARN" \
  --query 'Rules[].Actions[?Type==`authenticate-oidc`]'

Python (requests)

import requests

disc = requests.get(
    "https://idp.example.com/.well-known/openid-configuration", timeout=10
).json()
for key in ("issuer", "token_endpoint", "userinfo_endpoint"):
    print(key, disc.get(key))

Node (fetch)

const disc = await (
  await fetch("https://idp.example.com/.well-known/openid-configuration")
).json();
console.log(disc.issuer, disc.token_endpoint, disc.userinfo_endpoint);

Reference and tooling

The authoritative list of assigned status codes is theIANA HTTP Status Code Registry. For a searchable copy with the semantics summarised, use theHTTP status code reference on this site. To see exactly what a server is sending, theheader inspector shows the raw status line and response headers, and thecurl builder assembles the request flags for you.

Other 5xx codes