AWS: CloudFront 502 bad gateway error

Usually 502 error happens when Cloudfront unable to reach origin endpoint. Some of the common reasons are:

Backend is busy: Origin endpoint ( ELB -> EC2) is busy or load is higher than given threshold. If this is happening reguarly, its better to get more instance in auto scaling group or increase existing instance for larger capacity.

WAF rule: Some request might get blocked by WAF rule. So check cloudFront logs to verfiy, if needed modify your application or disable WAF rule ( not recommended).

DNS: If Endpoint has custom DNS, make sure DNS is reachable.

EC2 instances: All EC2 instances in origin endpoint are down or unhealthy.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s