Clients receive HTTP 502, 503, or 504 errors when attempting to connect to web servers running on EC2 instances configured to use Elastic Load Balancing.

HTTP 502 (Bad Gateway) errors can occur if either the web server or associated back-end application servers running on EC2 instances return an error message that cannot be parsed by Elastic Load Balancing (ELB).

HTTP 503 (Service Unavailable) errors can occur for several reasons, including:

  • Insufficient web server or back-end application server instance resources available to service client requests.
  • Web server instances or back-end application server instances fail the Elastic Load Balancing (ELB) heath check.
  • One or more processes running on web server instances or back-end application server instances are down or inaccessible via the expected TCP/IP port number (for example TCP port 80 for HTTP).
  • A security group or access control list (ACL) misconfiguration is preventing access to back-end application server instances.
  • You have not registered back-end instances in every Availability Zone that your Classic Load Balancer is configured to respond in.
  • Connection draining is not enabled for the Classic Load Balancer that your web server instances are registered with.

HTTP 504 (Gateway Timeout) errors can occur for the following reasons:

  • Web server instances or back-end application server instances are busy and cannot respond to requests within the default ELB idle timeout limit of 60 seconds.
  • Web server instances or back-end application server instances terminate connections before the load balancer does, resulting in premature connection terminations.
  • Apache web server instances have the TCP_DEFER_ACCEPT option enabled.
  • Apache web server instances have the event MPM enabled and have not optimally configured the prefork and worker MPMs given the default ELB idle timeout limit of 60 seconds.

Elastic Load Balancing, ELB, Auto Scaling, Classic, Timeout, HTTP 5xx, HTTP 502, 503, 504 errors, troubleshoot, httpd, Apache, Bad Gateway, Service Unavailable, Gateway Timeout, maintenance, network, VPN, tunnel, MPM


Did this page help you? Yes | No

Back to the AWS Support Knowledge Center

Need help? Visit the AWS Support Center

Published: 2016-09-16