Troubleshoot a Application load balancer : HTTP 504 error

Troubleshoot a Application load balancer : HTTP 504 error

March 19, 2021 / Nirav S

A 504 HTTP Bad Gateway is a known problem for system admins and developer alike. The most widely recognized explanation behind this mistake is that the back-end code didn’t react to an event call.

HTTP 504 error is caused by an idle timeout.

You can see on Cloudwatch metrics.

Step 1: Open the AWS Management Console.

Step 2: Go to EC2.

Step 3: Choose the Load Balancer and select your load balancer.

Step 4: From the Description tab, select edit attributes.

Load balancer attributes

Step 5: Type the value for an idle timeout in the range of 1 to 3600 seconds, and save it.

Edit Load balancer attributes

The second reason for HTTP 504 error is that a back-end instance closes its TCP connection with the load balancer before the idle timeout value has been reached.

The load balancer pre-opens TCP connection with the back-end instance for HTTP and HTTPS listeners based on the number of connections it has with active requests. So for a large number of requests, load balancer opens more pre-opened TCP connections and also the load balancer does not use a pre-opened connection immediately if it is not receiving many requests.

This relies upon how you arranged your backend to permit association reuse. Without keep-alive help, the load balancer needs to open another association for each request it gets.

Talk to AWS Certified Consultant

    Let Us Talk About Your AWS Development Requirements

    Have queries about your AWS project ideas and concepts? Please drop in your project details to discuss with our AWS experts, professionals and consultants.

    • Swift Hiring and Onboarding
    • Experienced and Trained AWS Team
    • Quality Consulting and Programming
    Let’s Connect and Discuss Your Project