What is 4XX and 5XX Error in CloudFront

What is 4XX and 5XX Error in CloudFront

July 1, 2020 / Eternal Team

In this blog we will discuss the different errors that will occur in cloud front.now let’s take some scenarios and try to understand what the errors are and how to solve them.

Suppose,

A web application and it’s being served from an EC2 instance, and we’ve also got some files in S3 as well. The website is sitting behind a cloud front distribution, and then we’ve got our users, and they are accessing the application using CloudFront. So then, imagine there’s some kind of problem with the website. So, something’s gone wrong and when that happens,then the CloudFront is going to return an HTTP status code, and it’s generally a 400 or a 500 status code,which means that something has gone badly wrong. If you’ve been using AWS for a while, you probably already are familiar with some of the 400 and 500 status codes.

So first, let’s take a look at the 400 errors.

4XX-5XX-Error-CloudFront

400 error is always a client side error. So, usually there’s something wrong with whatever the client is requesting. 400 error and that means a bad request.

For example 1

it’s a malformed request,maybe the request has come in an incorrect format.Moving on to 403, which always means access denied.So if you’re running a website,will need to be publicly accessible,otherwise your users are gonna get this 403 access denied error.

For example 2

if you’re using S3 to host your website,you will need to enable public access for the S3 objects,
and that includes permission to run the S3:GetObject API call. And if you don’t have public access on your S3 website,of course, your users are gonna see this 403 access denied error,
So the 403 one is definitely one that is worth remembering.

And then the last that I wanted to remind you about is the 404 error.You’ve probably seen this loads of times before when using the internet. It’s a really, really common error message.
It simply means the object does not exist. that 404 error that you often see
when you’ve tried to visit a webpage which doesn’t exist.Maybe you’ve typed in the address incorrectly, or maybe you tried to visit a page that no longer exists.

So, I just try to remember if it’s 404, it’s always my fault,…….:(

So moving on to server side errors, 500 errors are always server side issues.

4XX-5XX-Error-CloudFront

I’ve got a few examples here. Starting off with the 502,which is a bad gateway.

Generally, this means that CloudFront cannot connect to either the S3 bucket or EC2 instance
Which is serving your website. 503 which means service unavailable and this usually indicates
performance issues on your server.So the server is receiving more requests than it’s able to handle.

Finally, 504 which is a gateway timeout and this is what happens when you get the request expiring before a response is received from the server. And once again,that can also indicate a performance issue because the server is not able to respond to all the requests that are coming in.It’s often a performance related problem with the EC2 instance or the S3 bucket,and your ECZ instance cannot handle the amount of requests that are hitting your website.

So after all these above things you just need to know that 4xx error is for client side error and 5xx error is server side error.

Happy cloud computing…….

AWS-Consulting-Partner

Talk to AWS Certified Consultant

    Want to start a project?

    It’s simple.

    Contact us