// troubleshooting guide · aws cloudfront

CloudFront 502 Bad Gateway Error

Status
Workaround available
platforms:
AWS Console, custom origins (EC2, ALB, external servers)
updated:
November 17, 2026
reports:
5
Method
how we research
Share

RUNBOOK · aws-cloudfront/502-bad-gateway4 FIXES

// quick answer

CloudFront returns 502 when it can't complete a valid connection to your origin: most often the origin's TLS certificate doesn't match the origin domain, is expired, self-signed or missing intermediates, or the origin DNS doesn't resolve. Fix the certificate or the Host header forwarding.

Most likely fix: Test the origin TLS handshake

How to fix it

// try these in order, the most common fix is first

  1. FIX 1Test the origin TLS handshake

    1. 01Run openssl s_client -connect origin.example.com:443 -servername origin.example.com
    2. 02Check the certificate covers the origin hostname, isn't expired and that the chain includes intermediates
    3. 03Replace or reissue the certificate if needed
    Did this fix it?
  2. FIX 2Stop forwarding the viewer Host header

    1. 01Open Behaviors > Edit
    2. 02Change the origin request policy from AllViewer to AllViewerExceptHostHeader
    3. 03Save and retest
    Did this fix it?
  3. FIX 3Check origin protocol settings

    1. 01Open Origins > Edit
    2. 02Confirm Protocol (HTTPS only / Match viewer) and HTTPS port match the origin
    3. 03Set Minimum origin SSL protocol to a version the origin supports (TLSv1.2)
    Did this fix it?
  4. FIX 4Verify DNS for the origin

    1. 01Run dig origin.example.com from outside your network
    2. 02Make sure it resolves publicly; private DNS names need VPC origins
    Did this fix it?

Symptoms

502 ERROR 'The request could not be satisfied. CloudFront wasn't able to connect to the origin.'

Why it happens

  • C-01Origin certificate doesn't include the Origin domain name configured in CloudFront
  • C-02Expired, self-signed or incomplete certificate chain on the origin
  • C-03Origin only supports TLS versions or ciphers CloudFront doesn't accept
  • C-04Viewer Host header forwarded to an origin whose certificate doesn't cover it
  • C-05Origin domain name doesn't resolve in public DNS
  • C-06Lambda@Edge function returned an invalid response

// this guide also covers

  • cloudfront 502 bad gateway
  • cloudfront wasn't able to connect to the origin
  • cloudfront 502 ssl
  • cloudfront 502 error

Still not working?

If AWS CloudFront keeps failing, you're not alone. See every AWS CloudFront problem users report or the alternatives people switch to.

Have an app idea? Our small team builds any software: web and mobile apps, games, desktop, AI tools. Price agreed together.

Talk to us

Watch AWS CloudFront Get an email when its price changes, it has an outage, or we publish a new fix. No spam.

Fixed it? Share this guide

The same problem in other apps

All not loading, error messages & connection guides →

Other AWS CloudFront errors

All 12 AWS CloudFront errors and fixes →