TechBuzzPro

CloudFront 403 Troubleshooting: Find the Blocking Layer

· 7 min read · Apps & Browsers

In this article
  1. What a CloudFront 403 Actually Means
  2. Start With the x-cache Header
  3. Check WAF Rules and Managed Rules
  4. Verify Signed URLs and Cookies
  5. Inspect Origin Access Control (OAC) and S3 Bucket Policies
  6. Look at the Origin Server Itself
  7. Use CloudFront Logs and Error Headers
  8. Frequently Asked Questions

To find which layer is blocking your CloudFront 403 error, start by checking the x-cache response header: if it says Error from cloudfront, the block is at CloudFront or the origin; if it says Miss from cloudfront, the block is at the origin server. Then inspect CloudFront logs and the origin response headers to pinpoint whether the issue is a WAF rule, a signed URL/cookie, an origin access control (OAC) misconfiguration, or the origin itself returning 403.

What a CloudFront 403 Actually Means

HTTP 403 Forbidden means the server understood your request but refuses to authorize it. With CloudFront, this response can originate from several layers, each with its own set of rules and configuration. The challenge is that the error message alone rarely tells you which layer rejected the request. You need to systematically narrow it down.

Common causes include: an AWS WAF rule blocking the request, a missing or invalid signed URL or cookie, an origin access control (OAC) or origin access identity (OAI) misconfiguration, an S3 bucket policy denying access, or the origin server itself (e.g., a web server or application) returning 403. Each layer has distinct diagnostic signatures.

Start With the x-cache Header

Every CloudFront response includes an x-cache header. This is your first diagnostic clue. It tells you whether the response came from a CloudFront edge or from the origin.

  • Error from cloudfront – CloudFront itself generated the 403. This usually means a WAF rule, a signed URL/cookie check, or a CloudFront function blocked the request before it reached the origin.
  • Miss from cloudfront – CloudFront forwarded the request to the origin, and the origin returned the 403. The block is at the origin (S3 bucket policy, OAC, or the origin server itself).

If you see Error from cloudfront, you can narrow it down further by checking the x-amz-cf-error header (if present) and the CloudFront logs. If you see Miss from cloudfront, the problem is almost certainly at the origin.

Check WAF Rules and Managed Rules

AWS WAF is often the culprit for CloudFront 403s. If you have a web ACL associated with your distribution, a rule may be blocking the request. WAF can block based on IP addresses, country, SQL injection patterns, cross-site scripting, or rate-based rules.

To diagnose: go to the AWS WAF console, find the web ACL attached to your distribution, and look at the Sampled requests tab. It shows recent requests and whether they were allowed or blocked, and by which rule. If you see a blocked request, you can temporarily disable the rule to test, but be careful in production.

Common WAF-related 403s include: IP reputation lists blocking your IP, rate-based rules triggering due to high request volume, or managed rule groups (like the AWS Managed Rules) flagging a request as malicious. If the sampled requests show a rule action of “Block,” that’s your smoking gun.

Verify Signed URLs and Cookies

If your distribution is configured to require signed URLs or signed cookies, CloudFront will return a 403 if the signature is missing, expired, or invalid. This is a common cause for 403s on private content.

Check: does the URL contain a valid Policy, Signature, and Key-Pair-Id query parameter? Or does the request include a valid CloudFront-Signature cookie? Also verify that the key pair ID used to sign matches a trusted signer in your distribution’s settings.

A quick test: temporarily set the distribution’s “Restrict Viewer Access” to No and see if the 403 goes away. If it does, the issue is with your signing logic. Common mistakes include using the wrong key pair, an expired policy, or a policy that doesn’t match the exact URL (including the protocol and query string).

Inspect Origin Access Control (OAC) and S3 Bucket Policies

If your origin is an S3 bucket, CloudFront uses Origin Access Control (OAC) or the older Origin Access Identity (OAI) to fetch objects. If OAC is misconfigured, CloudFront can’t authenticate to S3, and S3 returns a 403.

For OAC, check that the bucket policy explicitly allows s3:GetObject for the CloudFront distribution’s principal (the OAC). The policy must include the correct aws:SourceArn condition. A common error is using an OAI policy with an OAC, or vice versa.

If you’re using OAI, verify that the bucket policy includes the OAI’s canonical user ID. Also check that the bucket is not publicly blocked in a way that conflicts with CloudFront access. The S3 bucket’s “Block Public Access” settings don’t affect CloudFront via OAC, but they can if you’re using a misconfigured setup.

To test: temporarily set the bucket policy to allow s3:GetObject for Principal: "*" (public read) and see if the 403 disappears. If it does, your OAC/OAI configuration is the problem. Remember to revert the policy afterward.

Look at the Origin Server Itself

If x-cache says Miss from cloudfront, the origin is returning the 403. This could be an application-level authorization failure, a web server rule (like Apache’s mod_rewrite or Nginx’s deny directive), or a firewall on the origin.

Check the origin server logs to see the exact reason for the 403. Common causes: the origin requires authentication (like a login cookie), the IP address of the CloudFront edge is blocked, or the Host header is not recognized. Also verify that the origin is not rejecting requests with a missing or incorrect User-Agent header.

If your origin is an Application Load Balancer (ALB) or EC2, ensure the security group allows traffic from CloudFront’s IP ranges. AWS publishes the current CloudFront IP ranges, and you can use them in your security group rules. If you’re using a custom origin, also check that the origin’s SSL certificate is valid and that CloudFront can connect successfully (check the distribution’s origin status in the console).

Use CloudFront Logs and Error Headers

CloudFront provides detailed logs that can help you pinpoint the blocking layer. Enable standard access logs (or real-time logs) and look at the x-edge-result-type field. Values like Error or LimitExceeded indicate a CloudFront-side block. The x-edge-detailed-result-type field gives even more detail, such as WAFBlocked or InvalidRequest.

Additionally, the x-amz-cf-error header in the response often contains an error code and description. For example, 403 - Request blocked by WAF or 403 - Invalid signature. This header is only present when CloudFront itself generates the error.

If you don’t have logs enabled, you can temporarily enable them for a short period to capture the issue. Logs are stored in S3, so you need an S3 bucket to receive them.

Frequently Asked Questions

Why do I get a 403 even though my S3 bucket is public?

If your S3 bucket is public but you’re still getting a 403, the issue is likely that CloudFront is not configured to access the bucket properly. With OAC, the bucket policy must explicitly allow the CloudFront distribution. A public bucket doesn’t automatically grant CloudFront access if OAC is enabled, because OAC uses a special principal that requires a bucket policy. Also, if you’re using OAI, the bucket must have a policy that includes the OAI’s canonical user ID. Double-check your bucket policy and the distribution’s origin settings.

How do I know if a WAF rule is blocking my request?

Check the AWS WAF console for the web ACL attached to your distribution. Go to the “Sampled requests” tab and look for requests with an action of “Block”. The sample will show which rule blocked the request. You can also enable WAF logging to get more detailed information, including the rule ID and the reason for the block. If you see a block, you can test by temporarily disabling the rule (if safe) to confirm.

Can a signed URL expire and cause a 403?

Yes. Signed URLs include a policy that specifies an expiration time. If the current time is past the expiration, CloudFront returns a 403. This is a common issue when URLs are cached or shared after they expire. Check the Policy parameter in the URL and decode it to see the expiration timestamp. Also ensure the signature is generated with the correct key pair and that the policy matches the exact URL (including the query string).

What does the x-cache header value “Error from cloudfront” mean?

It means CloudFront itself generated the error response, not the origin. This indicates the block happened at the edge, such as a WAF rule, a signed URL/cookie failure, or a CloudFront function. The origin was never contacted. If you see this, focus your troubleshooting on CloudFront’s own features: WAF, signed URLs, functions, or the distribution’s settings.

My origin is an ALB, and I’m getting 403. What should I check?

First, confirm that the ALB is actually returning the 403 by checking the x-cache header (should be Miss from cloudfront). Then check the ALB access logs to see the HTTP status. Common causes: the ALB’s security group doesn’t allow traffic from CloudFront IPs, the ALB requires authentication (like an OIDC or Cognito user pool), or the target group’s health check is failing, causing the ALB to return 403. Also ensure the ALB listener is configured for HTTPS with a valid certificate that CloudFront accepts.