Resource does not exist or URL is wrong
- How to check
- Request the same path on the origin directly
- Fix
- Upload the object or correct the link
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.
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.
Four quick questions, then a straight answer.
From your answers, this is quietly costing you traffic and nobody has the hours to chase it. Scaplet finds every affected page, drafts the fixes and tracks how AI answers mention you.
A data platform shipped 46 fixes without a ticket.
This looks handled. Re-check after a redesign, a migration or a big content push; that is when it breaks.
Your site is small and you have the time. Work through the steps on this page, starting with the pages that get the most traffic.
/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".
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;
}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.Cache-Control: max-age or s-maxageno-store, no-cache, private on 404, 410, 414, 501If 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.
Request the same path on the origin host. A 404 there means CloudFront is only passing it on.
curl -sI https://d111111abcdef8.cloudfront.net/path and compare status and headers with the origin.
In the distribution's custom error pages and response codes, check the page path for each code and the response code CloudFront returns.
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.
curl -sI https://origin.example.com/path | head -n 1
curl -sI https://d111111abcdef8.cloudfront.net/path | head -n 13 questions people ask next, answered from the sources on this page.
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.
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.
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.
Run the free audit, then approve the fixes. Every change can be undone.