504 Gateway Time-Out when launching load balancer?

0

Hello, i have 2 ec2 instances. I want to access them through the load balancer. But somehow it tells me 504 Gateway Time-Out in the browser. I go to the target groups and it tells me the 2 instances are unhealthy.
Why do I get this error? The aws documentations didnt help me

DSV
已提问 3 年前4924 查看次数
2 回答
-1

Hello

A 504 HTTP Bad Gateway refers to a server-side connection issue.

As seen here [2]common cause of the error when using an ALB is:

-The back-end instance did not respond to the request within the correctly configured idle timeout i.e. the back-end instance took more time to respond than the configured idle timeout of the load balancer.
-The load balancer failed to establish a connection to the target before the connection timeout expired (10 seconds).
-The target returns a content-length header that is larger than the entity body. The load balancer timed out waiting for the missing bytes.

Additionally you have mentioned that healthchecks are failing for the loadbalancer target group.A failed healthcheck indicates a connection issue with backend.This is what is causing the 504 errors being returned(-The load balancer failed to establish a connection to the target before the connection timeout expired (10 seconds)).

That said, you need to make the targets healthy first so that you can evaluate any other cause of the 504.

To resolve the 504 and healthcheck issue,consider the following when troubleshooting:

-Verify that your application is running.
Use the service command to check the status of services on Linux targets. For Windows targets, check the Services tab of the Windows Task Manager.If the service is stopped, start the service. If the service isn't recognized, verify that the required service is installed.

-Verify that the target is listening for traffic on the health check port
Run the [netstat -plnt] command on linux to verify which ports your server is listening to.For Windows targets, you can use the [netstat] command.

-Verify that your application responds to the load balancer's health check requests accordingly.

-Check the security group of the backend instances if they allow traffic on that port.

-Increase health check time out to see if application will respond in that period[1]

-Try and increase the capacity of instance type ,it could be that your application is taking longer to respond.

I hope this helps!

Reference

Modify the health check settings of a target group
[1]https://docs.aws.amazon.com/elasticloadbalancing/latest/network/target-group-health-checks.html#modify-health-check-settings

Troubleshooting HTTP 504 Error
[2]https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-troubleshooting.html#http-504-issues

How do I troubleshoot and fix failing health checks for Application Load Balancers?
[3]https://aws.amazon.com/premiumsupport/knowledge-center/elb-fix-failing-health-checks-alb/

已回答 3 年前
  • How I Verify that the targets are listening for traffic on the health check port if the targets are ip addresses of vpc endpoint enis to invoke a lambda with API gateway ?

-1

Hello

A 504 HTTP Bad Gateway refers to a server-side connection issue.

As seen here [2]common cause of the error when using an ALB is:

-The back-end instance did not respond to the request within the correctly configured idle timeout i.e. the back-end instance took more time to respond than the configured idle timeout of the load balancer.
-The load balancer failed to establish a connection to the target before the connection timeout expired (10 seconds).
-The target returns a content-length header that is larger than the entity body. The load balancer timed out waiting for the missing bytes.

Additionally you have mentioned that healthchecks are failing for the loadbalancer target group.A failed healthcheck indicates a connection issue with backend.This is what is causing the 504 errors being returned(-The load balancer failed to establish a connection to the target before the connection timeout expired (10 seconds)).

That said, you need to make the targets healthy first so that you can evaluate any other cause of the 504.

To resolve the 504 and healthcheck issue,consider the following when troubleshooting:

-Verify that your application is running.
Use the service command to check the status of services on Linux targets. For Windows targets, check the Services tab of the Windows Task Manager.If the service is stopped, start the service. If the service isn't recognized, verify that the required service is installed.

-Verify that the target is listening for traffic on the health check port
Run the [netstat -plnt] command on linux to verify which ports your server is listening to.For Windows targets, you can use the [netstat] command.

-Verify that your application responds to the load balancer's health check requests accordingly.

-Check the security group of the backend instances if they allow traffic on that port.

-Increase health check time out to see if application will respond in that period[1]

-Try and increase the capacity of instance type ,it could be that your application is taking longer to respond.

I hope this helps!

Reference

Modify the health check settings of a target group
[1]https://docs.aws.amazon.com/elasticloadbalancing/latest/network/target-group-health-checks.html#modify-health-check-settings

Troubleshooting HTTP 504 Error
[2]https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-troubleshooting.html#http-504-issues

How do I troubleshoot and fix failing health checks for Application Load Balancers?
[3]https://aws.amazon.com/premiumsupport/knowledge-center/elb-fix-failing-health-checks-alb/

已回答 3 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则