Why do I receive an HTTP 5xx error when I connect to web servers that run on EC2 instances that are configured to use Classic Load Balancing?

3 minute read
0

I received an HTTP 502, 503, or 504 errors when I tried to connect to web servers. The web servers run on EC2 instances that are configured to use Classic Load Balancing.

Resolution

HTTP 502 (Bad Gateway)

You can receive an HTTP 502 error if a Classic Load Balancer can't parse a message. Either the web server or associated backend application servers that run on EC2 instances return a message that a Classic Load Balancer can't parse. For more information, see How do I troubleshoot HTTP 502 errors when I make requests through a Classic Load Balancer?

HTTP 503 (Service Unavailable)

HTTP 503 errors occur for the following reasons:

  • The surge queue is full. Review the SpilloverCount metric to check that your instances have the capacity to handle the request rate.
  • There are no healthy instances. Make sure that you have healthy instances in every Availability Zone that your load balancer responds. To do this, review the HealthyHostCount metric. For more information, see Troubleshoot a Classic Load Balancer: health checks.
  • You didn't register at least one instance in every Availability Zone that your load balancer responds in. If you can't confirm that an instance is registered in each Availability Zone, then turn on cross-zone load balancing.
  • Connection draining isn't turned on for the Classic Load Balancer that your web server instances are registered with.

For more information, see How do I troubleshoot HTTP 503 errors returned while using Classic Load Balancer?

HTTP 504 (Gateway Timeout)

HTTP 504 errors occur for the following reasons:

  • Web server instances or backend application server instances are busy and can't respond to requests within the configured Elastic Load Balancing (ELB) idle timeout limit. For more information, see How do I troubleshoot high latency on my ELB Classic Load Balancer?
  • Web server instances or backend application server instances terminate connections before the load balancer does. This results in premature connection terminations.
  • Web server instances or backend application server instances crash or restart server processes when requests are in flight. This results in the server breaking all connections.
  • Apache web server instances have the AcceptFilter http/https option turned on. This instructs Apache to implement TCP_DEFER_ACCEPT on the connections.
  • The event (from the Apache website) MPM is turned on for the Apache web server instances, but the prefork and worker (from the Apache website) MPMs aren't optimally configured. The default ELB idle timeout limit is 60 seconds. For more information, see What are the optimal settings for using Apache or NGINX as a backend server for ELB?

For more information, see How do I troubleshoot HTTP 504 errors returned while using a Classic Load Balancer?

Related information

What is Elastic Load Balancing?

Tutorial: Create a Classic Load Balancer

Configure health checks for your Classic Load Balancer

Monitor your Classic Load Balancer

AWS OFFICIAL
AWS OFFICIALUpdated a year ago