CloudFront shows `502 ERROR. The request could not be satisfied. CloudFront wasn't able to connect to the origin.`
IntermediateTroubleshootingRoute 53, CloudFront, API Gateway and Messaging
Answer
Likely causes → The CloudFront → origin TLS handshake fails: the origin certificate does not match the origin domain name, it is self-signed or expired, or the chain is incomplete. Or the origin protocol policy is wrong (HTTPS-only to an origin that only speaks HTTP), or the SG blocks CloudFront.
Diagnose →
aws cloudfront get-distribution-config --id E123ABC \
--query 'DistributionConfig.Origins.Items[].[DomainName,CustomOriginConfig]'
openssl s_client -connect origin.example.com:443 -servername origin.example.com </dev/null 2>/dev/null | openssl x509 -noout -subject -dates
Fix →
- Use an origin domain covered by a valid public certificate (for example, an ACM certificate on the ALB for
origin.example.com), and forward the matching Host or SNI - Match the origin protocol policy and ports to what the origin serves
- Allow the
com.amazonaws.global.cloudfront.origin-facingprefix list on the ALB SG
Prevent → Monitor origin certificate expiry, and use CloudFront VPC origins or origin-facing prefix lists for ALB origins.
More on Route 53, CloudFront, API Gateway and Messaging
You created a public hosted zone and records for `example.com`, but `dig example.com` returns `NXDOMAIN` or old records.Beginner`InvalidChangeBatch: RRSet of type CNAME with DNS name example.com. is not permitted at apex in zone example.com.`BeginnerThe primary Region is down, but Route 53 failover records still send traffic to it.IntermediateA Route 53 health check reports `Failure: Connection timed out` for an endpoint that works fine from your laptop.IntermediateYou changed an A record an hour ago, but some users still reach the old server, and a newly created name returned `NXDOMAIN` for a while.AdvancedCloudFront returns `403 AccessDenied` (S3 XML) for every object after you switched the S3 origin to Origin Access Control.Intermediate