Free auditStart free
GuideError · CDN and hosting errors

CloudFront 404 Not Found

Fix an Amazon CloudFront 404: wrong origin path, missing object, a custom error page that returns 404, and how long CloudFront caches the error before retrying.

4 min
read
8
sources
Nov 1, 2026
updated
Scaplet Editorial Team
author
In one line

CloudFront returns a 404 when the requested object does not exist at the origin, the origin path is wrong, the origin itself sent a 404, or a custom error page is missing. CloudFront also caches error responses for 10 seconds by default, so a fixed object can still 404 briefly. Test the origin URL directly, then check origin path and error page settings.

30-second check

Where does your site stand?

Four quick questions, then a straight answer.

1/4Have you checked your own site for this?
Summarize this page withChatGPTClaudePerplexityGoogleAI Mode
02Check it

Origin path and default root object

If the origin path is populated, its value is appended to the path of each request before CloudFront forwards it. A request for /index.html with origin path /site fetches /site/index.html from the origin. A wrong value there is a classic cause of a 404 on every URL.

The default root object applies only to the root URL. With index.html as the default root object, a request for /install/ is not rewritten to /install/index.html, even if that file exists. CloudFront's docs contrast this with S3 website index documents, which are returned for subdirectories. The string cannot start with a slash, since /index.html "can lead to a 403 Access Denied error".

CloudFront Function (viewer request) that appends index.html, from the AWS examples
async function handler(event) {
  var request = event.request;
  var uri = request.uri;

  // Check whether the URI is missing a file name.
  if (uri.endsWith('/')) {
    request.uri += 'index.html';
  }
  // Check whether the URI is missing a file extension.
  else if (!uri.includes('.')) {
    request.uri += '/index.html';
  }

  return request;
}
03Error caching rules from the docs

Why the 404 sticks after you fix it

CloudFront caches error responses for a default duration of 10 seconds, controlled by the Error Caching Minimum TTL per status code. After that it asks the origin again. If the origin adds Cache-Control: max-age or s-maxage, CloudFront caches the error for the greater of the header value and the minimum TTL. For 404, 410, 414 and 501 it will not cache when the origin sends no-store, no-cache or private.
Setting

Error caching minimum TTL

Behavior
10 seconds by default, set per status code
Setting

Origin sends Cache-Control: max-age or s-maxage

Behavior
Greater of the header and the minimum TTL, capped by the behavior's Maximum TTL
Setting

no-store, no-cache, private on 404, 410, 414, 501

Behavior
Error response is not cached
Setting

S3 origin with a minimum TTL of 0

Behavior
Still 1 second for S3 origin errors

If a cached 404 lasts longer than you want and the object is back, invalidate the URL of the requested object. Invalidate each object separately when many return errors.

04How it works

Reproduce and verify

  1. 1

    Test the origin directly

    Request the same path on the origin host. A 404 there means CloudFront is only passing it on.

  2. 2

    Request through CloudFront

    curl -sI https://d111111abcdef8.cloudfront.net/path and compare status and headers with the origin.

  3. 3

    Review error pages

    In the distribution's custom error pages and response codes, check the page path for each code and the response code CloudFront returns.

  4. 4

    Check logs

    With standard logs, the sc-status column holds the status sent to the viewer, while x-edge-result-type holds the result type from the origin. If you changed the response code, sc-status shows your value and x-edge-result-type can still read Error.

Compare origin and CloudFront
curl -sI https://origin.example.com/path | head -n 1
curl -sI https://d111111abcdef8.cloudfront.net/path | head -n 1
05Explained

SEO and crawler notes

Googlebot sees the status CloudFront sends. Google drops 4xx URLs from the index over time, so a transient 404 from a bad deploy matters less than a persistent one. Do not use CloudFront's option to return 200 with an error page for missing content: Google would see a soft 404. See 404 Not Found for crawl behavior.
Questions

Asked a lot.

3 questions people ask next, answered from the sources on this page.

01Why does CloudFront return 404 for a file that exists in S3?

Check the origin path, which is appended to every request, and the exact object key. A default root object also only applies to the root URL, not subdirectories.

02How long does CloudFront cache a 404?

10 seconds by default, per the Error Caching Minimum TTL, or longer if the origin sends max-age or s-maxage. Invalidate the URL if you need it cleared sooner.

03Can CloudFront turn a 500 into a 404?

Yes. With custom error pages configured, AWS says any error code might be translated to 404, for example when the error page object has been deleted.

Sources · 8

Every fact, linked and dated.

Official docs first. The date is when we last opened each page.
  • amazon.com
  • google.com
  1. 01HTTP 404 status code (Not Found)docs.aws.amazon.com · checked 2026-11-01
  2. 02Generate custom error responsesdocs.aws.amazon.com · checked 2026-11-01
  3. 03Control how long CloudFront caches errorsdocs.aws.amazon.com · checked 2026-11-01
  4. 04Change response codes returned by CloudFrontdocs.aws.amazon.com · checked 2026-11-01
  5. 05Specify a default root objectdocs.aws.amazon.com · checked 2026-11-01
  6. 06Add index.html to request URLs without a file namedocs.aws.amazon.com · checked 2026-11-01
  7. 07Invalidate files to remove contentdocs.aws.amazon.com · checked 2026-11-01
  8. 08How HTTP status codes affect Google's crawlersdevelopers.google.com · checked 2026-11-01
Free · 2 minutes

Tools point. Agencies advise. This one ships.

Run the free audit, then approve the fixes. Every change can be undone.

Free, no card60 secondsNobody will call you
  • 46 fixes shipped without a ticket Brightpipe
  • 0→7 ChatGPT citations in six weeks Paylane