The load balancer could not establish a connection to the target before the 10 second connection timeout
- First thing to check
- Security groups and route tables between the ALB subnets and the target port; is the target process listening
An Application Load Balancer 504 means the target did not connect or reply in time. Read the -1 timing fields in the access log to pick the cause, then fix it.
An Application Load Balancer returns 504 when it cannot connect to a target within 10 seconds, or when the target accepts the connection but sends nothing before the idle timeout (60 seconds by default). The access log tells you which: -1 in request_processing_time points to the connect step, -1 in target_processing_time to the idle timeout. Fix the network path, or speed up or stream the response.
Four quick questions, then a straight answer.
From your answers, this is quietly costing you traffic and nobody has the hours to chase it. Scaplet finds every affected page, drafts the fixes and tracks how AI answers mention you.
A data platform shipped 46 fixes without a ticket.
This looks handled. Re-check after a redesign, a migration or a big content push; that is when it breaks.
Your site is small and you have the time. Work through the steps on this page, starting with the pages that get the most traffic.
content-length header larger than the body, so the ALB waits for missing bytesclient --> ALB node --(connect, 10 s limit)--> target
'--(idle timeout, default 60 s)--> first response bytes
connect clock expires -> 504, request_processing_time = -1
idle clock expires -> 504, target_processing_time = -1curl -sS -o /dev/null -w "%{http_code} %{time_total}s\n" https://httpbin.org/status/504
# observed: 504 0.87s (a fixed 504, answered at once)
curl -sS -o /dev/null -w "%{http_code} %{time_total}s\n" https://httpbin.org/delay/3
# observed: 200 3.79s (a slow but successful request)curl -sS -o /dev/null -w "%{http_code} %{time_total}s\n" https://your-alb.example/slow-report
# A 504 near 60s matches the default idle timeout; a 504 near 10s matches the connect timeoutawk '$9 == 504 {
why = ($6 == -1) ? "no connection to target" : ($7 == -1) ? "target silent past idle timeout" : "other"
print $2, $6, $7, why
}' alb-access.logThe access log is the decisive source. Field 6 is request_processing_time, field 7 is target_processing_time, field 9 is elb_status_code. AWS documents -1 in the first when the TCP connection cannot be established before the 10 second timeout (it can also mean the target closed the connection before the idle timeout or the client sent a malformed request), and -1 in the second when the registered target does not respond before the idle timeout.
I ran that awk program on two constructed log lines that follow the field layout in AWS's example entry, one with -1 -1 -1 and one with 0.000 -1 -1. It printed no connection to target and target silent past idle timeout. It is a first filter, not a diagnosis: confirm the cause against the table above.
Resources:
myLoadBalancer:
Type: 'AWS::ElasticLoadBalancingV2::LoadBalancer'
Properties:
Name: my-alb
Type: application
LoadBalancerAttributes:
- Key: "idle_timeout.timeout_seconds"
Value: "120"On the target, confirm the app is listening on the target group's port, on an address the load balancer can reach.
The target's security group must allow traffic from the load balancer on the target port. AWS's guide says the same for the health check port and protocol.
The subnet's network ACL must allow traffic from the targets back to the load balancer nodes on ephemeral ports 1024-65535. If it blocks that return traffic, AWS lists the result as a 504.
Check the target group's health status. A target in a failing state still receives traffic if every target is failing, because AWS documents that the load balancer then fails open and routes to all targets regardless of health.
Google treats a 504 as a server error. Its documentation says 5xx and 429 responses prompt its crawlers to temporarily slow down, and that already indexed URLs are preserved but eventually dropped. A single endpoint that times out costs little. A listener-wide cause, such as a blocked network ACL, turns every URL into a 504, and the crawl rate falls with it. Look for timeouts through timeout errors and 5xx server errors.
3 questions people ask next, answered from the sources on this page.
60 seconds. The valid range is 1 to 4000 seconds. A request that sends no data for longer than that gets a 504 from the load balancer if the target has not started responding.
Look at the two timing fields on the 504 line. AWS documents request_processing_time as -1 when the TCP connection to the target is not established within 10 seconds, and target_processing_time as -1 when the target does not respond before the idle timeout.
It can. AWS lists a Lambda target whose service did not respond before the connection timeout expired as a 504 cause. Separately, a Lambda function that exceeds its own timeout appears as a 502 on the ALB, so check which status you see.
Run the free audit, then approve the fixes. Every change can be undone.