Skip to content

How do I troubleshoot connection errors that I get with my Application Load Balancers over HTTP?

5 minute read
0

I receive connection errors when I send an HTTP request to my Application Load Balancer.

Short description

Application Load Balancers have two separate TCP connections, one with the client and one with the target. There isn't a one-to-one relationship between client TCP connections and target TCP connections. An Application Load Balancer might have several concurrent TCP connections open with a single target. Clients send requests to the load balancer over the frontend TCP connection. The Application Load Balancer forwards the request to any target in the target group over the backend TCP connections. For more information, see HTTP connections.

To troubleshoot TCP connection issues, first identify whether the issue is in the backend or the frontend connection. Then, troubleshoot the connection.

Note: An Application Load Balancer is a Layer 7 load balancer that supports both HTTP and HTTPS listeners.

Resolution

Identify the TCP connection with issues

To check for connection issues on Linux or macOS, run the following command:

telnet ALB_DNS_name ALB_listener_port

Note: Replace ALB_DNS_name with the load balancer's DNS name and ALB_listener_port with the listener port. You can run a netcat test instead.

On Windows, run the following Test-NetConnection command instead:

Test-NetConnection -ComputerName ALB_DNS_name -Port ALB_listener_port

Note: Replace ALB_DNS_name with the load balancer's DNS name and ALB_listener_port with the listener port.

If the client connects to the Application Load Balancer, then you receive the following output:

For telnet:

Connected to ALB_DNS_name

For Test-NetConnection:

TcpTestSucceeded : True

Note: A successful test confirms Layer 4 (TCP) reachability to one load balancer node at that moment. Each Application Load Balancer has one IP address per active Availability Zone, and node IPs can change. Test the DNS name rather than a single resolved IP address. A successful TCP test doesn't confirm that the application responds. Use the curl check in the backend section to verify Layer 7 (HTTP) connectivity.

Troubleshoot frontend connectivity issues with the client

Troubleshoot timeout issues

Verify that the load balancer's security group and the subnet's network access control list (network ACL) allow traffic from the client. Also, verify that intermediate devices between the load balancer and client, such as firewalls, allow client traffic.

If your Application Load Balancer is public, then verify that the load balancer has a route out to the internet. If the load balancer is private, then verify that it has a route to the load balancer's subnets within the virtual private cloud (VPC). For example, configure an AWS Site-to-Site VPN or AWS Direct Connect connection.

Verify that you used the correct subnet

If the load balancer is in the incorrect subnet, then you experience intermittent timeout issues.

For example, you have a public Application Load Balancer in two Availability Zones, with subnet A in us-east-1a and subnet B in us-east-1b. If the connections occasionally fail, then verify that both subnet A and subnet B have a route out to the internet.

Troubleshoot backend connectivity issues with the target

Even if you can connect to the load balancer, the backend target might not be reachable.

To test connectivity with the backend, run the following command to the Application Load Balancer's DNS:

curl ALB_DNS:listener_port -v

Note: Replace ALB_DNS with the load balancer's DNS and listener_port with the listener port.

Example output:

* Trying ALB_public_IP:80...
* Connected to ALB_DNS (public IP) port listener_port
> GET / HTTP/1.1
> Host: <ALB DNS name>
> User-Agent: curl/8.4.0
> Accept: /
< HTTP/1.1 200 OK  
...  
<h1>Hello World</h1>  
< Server: Apache

If the connection to the backend fails because of TCP timeouts between the load balancer and the target, then you receive a 504 error.

Example output:

< HTTP/1.1 504 Gateway Timeout
< Server: awselb/2.0

If the connection to the backend fails because the target sent a TCP reset (TCP RST), then you receive a 502 error.

Example output:

< HTTP/1.1 502 Bad Gateway
< Server: awselb/2.0

For more information about HTTP error codes, see The load balancer generates an HTTP error.

To troubleshoot backend connection issues, complete the following actions:

  • Verify that the load balancer's security group and network ACL allow outbound traffic to the target.
  • Verify that the target's security group and network ACL allow inbound traffic from the load balancer.
  • Verify that your target is listening on the target group port.
  • Check whether a firewall blocks Application Load Balancer requests to the target.
  • Test connectivity from another Amazon Elastic Compute Cloud (Amazon EC2) instance within the same subnet as one of the Application Load Balancer nodes. This test helps identify whether the issue is with target networking or with the load balancer.

Related information

How do I troubleshoot client SSL/TLS negotiation errors when I connect to an Application Load Balancer that uses HTTPS?