Free auditStart free
GuideError · CDN and hosting errors

ALB 504 Gateway Timeout

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.

5 min
read
5
sources
Oct 30, 2026
updated
Scaplet Editorial Team
author
In one line

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.

30-second check

Where does your site stand?

Four quick questions, then a straight answer.

1/4Have you checked your own site for this?
Summarize this page withChatGPTClaudePerplexityGoogleAI Mode
01Causes listed in the AWS troubleshooting guide

The six ways an ALB produces a 504

A 504 from an Application Load Balancer is generated by the load balancer, not by your application. It means the ALB waited for the target and gave up. AWS's troubleshooting guide lists six causes, and two of them cover most real cases: a connection that never gets established, and a target that connects but stays silent.
Cause

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
Cause

The target connected but did not respond before the idle timeout elapsed

First thing to check
How long the slow request really takes; the ALB idle timeout; whether the app can send bytes sooner
Cause

The subnet's network ACL did not allow traffic from the targets to the load balancer nodes on ephemeral ports 1024-65535

First thing to check
Network ACL outbound rules on the target subnet
Cause

The target returns a content-length header larger than the body, so the ALB waits for missing bytes

First thing to check
The app or a proxy in front of it that rewrites the body after setting the header
Cause

The target is a Lambda function and the Lambda service did not respond before the connection timeout expired

First thing to check
Lambda function timeout and cold start time
Cause

The ALB hit a 10 second SSL handshake timeout when connecting to a target

First thing to check
TLS configuration on a target group that uses HTTPS
Request path and the two clocks the ALB runs
client --> 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  = -1
02Fix it on your stack

Check it in 2 minutes

Start by timing the failing request from outside, then read the access log. The first two commands use a public test service to show output shape. Replace the URL with your own to time a failing endpoint.
Public test endpoint: a 504 status, and a request that takes a few seconds
curl -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)
Your own ALB: time the failing URL (needs your domain)
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 timeout
Classify 504s in downloaded, unzipped ALB access logs
awk '$9 == 504 {
  why = ($6 == -1) ? "no connection to target" : ($7 == -1) ? "target silent past idle timeout" : "other"
  print $2, $6, $7, why
}' alb-access.log

The 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.

03Your call

Fix an idle-timeout 504

The idle timeout is the time a connection can sit with no data sent or received before the load balancer closes it. AWS says to send at least 1 byte of data before each idle timeout elapses for long operations, to raise the timeout as needed, and to keep the application's own idle timeout larger than the load balancer's. The default is 60 seconds and the valid range is 1 to 4000 seconds. A raised timeout is the stopgap; moving long work out of the request path is the fix.
If this fits

Raise the idle timeout when

  • The slow request is legitimate, such as a report or an upload
  • The response takes a bounded time you can name
  • You also raised the app server's own keep-alive above the ALB value
Or

Change the app instead when

  • The request time grows with data size or load
  • A downstream call is the slow part and could run as a background job
  • You can send partial bytes early to keep the connection active
CloudFormation: set the ALB idle timeout (from the AWS docs example)
Resources:
  myLoadBalancer:
    Type: 'AWS::ElasticLoadBalancingV2::LoadBalancer'
    Properties:
      Name: my-alb
      Type: application
      LoadBalancerAttributes:
        - Key: "idle_timeout.timeout_seconds"
          Value: "120"
04How it works

Fix a connect-timeout 504

A connect timeout is a network or process problem, not a slowness problem. Work through the path in order, because each layer is separate.
  1. 1

    Is the target listening

    On the target, confirm the app is listening on the target group's port, on an address the load balancer can reach.

  2. 2

    Security groups

    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.

  3. 3

    Network ACLs

    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.

  4. 4

    Target health

    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.

05Explained

What an ALB 504 means for SEO

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.

Sources · 5

Every fact, linked and dated.

Official docs first. The date is when we last opened each page.
  • amazon.com
  • google.com
  1. 01AWS: Troubleshoot your Application Load Balancersdocs.aws.amazon.com · checked 2026-11-01
  2. 02AWS: Application Load Balancer attributesdocs.aws.amazon.com · checked 2026-11-01
  3. 03AWS: Access logs for your Application Load Balancerdocs.aws.amazon.com · checked 2026-11-01
  4. 04AWS: Health checks for Application Load Balancer target groupsdocs.aws.amazon.com · checked 2026-11-01
  5. 05How HTTP status codes affect Google's crawlersdevelopers.google.com · checked 2026-11-01
Questions

Asked a lot.

3 questions people ask next, answered from the sources on this page.

01What is the default ALB idle timeout?

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.

02How do I tell a connect timeout from an idle timeout in the access log?

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.

03Does a Lambda target cause ALB 504s?

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.

Free · 2 minutes

Tools point. Agencies advise. This one ships.

Run the free audit, then approve the fixes. Every change can be undone.

Free, no card60 secondsNobody will call you
  • 46 fixes shipped without a ticket Brightpipe
  • 0→7 ChatGPT citations in six weeks Paylane