Easy Guide to Setting Up AWS Cloudfront Error Pages


3 min read

Easy Guide to Setting Up AWS Cloudfront Error Pages

Photo by Erik Mclean on Unsplash


Imagine you visit a website delivered through AWS CloudFront. If something goes wrong on the server behind the scenes, you might see a confusing error message on your screen.

Such default error messages have the potential to impede user experience, ultimately affecting business outcomes. Providing customized content in these scenarios would offer greater convenience.

Enter AWS CloudFront Error Pages! These allow you to craft personalized messages for users, elucidating the problem and possibly providing guidance. This ensures your visitors aren't left in a state of confusion. It's an effective method for enhancing your website's user experience!

How do CloudFront Error Pages function?

To utilize AWS CloudFront Error Pages, you first need to determine which error code you want to trigger an error page. The CloudFront Error Pages operate based on error codes.

For instance:

Let's say a user is attempting to access certain content and receives a 404 error code as a response. In this case, we recognize that when a 404 error code is received, we should display a customized response to the user.

Therefore, we can configure the system so that when a 404 error occurs, a tailored response is presented to the user, ensuring the continuity of their experience and the integrity of the application.

Benefits of CloudFront Error Pages

  1. Improved User Experience

Custom error pages enhance the user's experience by delivering personalized responses when errors occur.

  1. Preserved Application Integrity

Custom responses shield users from the inner workings of the application, maintaining its integrity.

  1. Error Response Caching Capability

CloudFront error pages enable caching of error responses, reducing the burden on application servers.

How to configure Cloudfront Error Pages?

  1. Go to the error pages tab for the respective Cloudfront distribution.

  2. Click on the "Create custom error response" button

  3. Select the error code for which you want to send the custom response.

  4. Set the caching period. Note that the period is in seconds

  5. Select whether you want to send customized response or not by switching between "Yes" or "No".

  6. If you opt for a customized response then provide the path of the page which should be served as the custom response.

  7. Select the new status code you need to send along with this new request.

  8. Lastly, click on the "Create custom error response" button


In the below screenshot, we have considered a case where we need to send a customized response for all the 404 errors. We have configured the caching period for 10 seconds and a 404.html response page.

AWS Cloudfront Error Pages Screenshot


CloudFront Error Pages are a crucial aspect of managing and optimizing web content delivery through AWS CloudFront. In this comprehensive guide, we delve into the fundamentals of CloudFront Error Pages, exploring what they are, how they work, and why they matter for website owners and developers.

Whether you're new to AWS CloudFront or looking to optimize your web delivery strategy, this guide will provide you with valuable insights into leveraging CloudFront Error Pages effectively.