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

Canonical: https://scaplet.com/errors/cdn/alb-504-gateway-timeout

Guide AWS Error · CDN and hosting errors

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 with [ChatGPT](https://chatgpt.com/?hints=search&q=Summarize%20https%3A%2F%2Fscaplet.com%2Ferrors%2Fcdn%2Falb-504-gateway-timeout%20(%22ALB%20504%20Gateway%20Timeout%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Claude](https://claude.ai/new?q=Summarize%20https%3A%2F%2Fscaplet.com%2Ferrors%2Fcdn%2Falb-504-gateway-timeout%20(%22ALB%20504%20Gateway%20Timeout%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Perplexity](https://www.perplexity.ai/search?q=Summarize%20https%3A%2F%2Fscaplet.com%2Ferrors%2Fcdn%2Falb-504-gateway-timeout%20(%22ALB%20504%20Gateway%20Timeout%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [![Google](/logos/ai/google-color.svg)AI Mode](https://www.google.com/search?udm=50&q=Summarize%20https%3A%2F%2Fscaplet.com%2Ferrors%2Fcdn%2Falb-504-gateway-timeout%20(%22ALB%20504%20Gateway%20Timeout%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.)

On this page

## 5 parts, 5 minutes.

1. [The six ways an ALB produces a 504 01](#the-six-ways-an-alb-produces-a-504)
2. [Check it in 2 minutes 02](#check-it-in-2-minutes)
3. [Fix an idle-timeout 504 03](#fix-an-idle-timeout-504)
4. [Fix a connect-timeout 504 04](#fix-a-connect-timeout-504)
5. [What an ALB 504 means for SEO 05](#what-an-alb-504-means-for-seo)

_01_Causes 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](/glossary/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
```

_02_Fix 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
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)
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
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.

**Access logs must already be on**Access logging is optional and is written to S3. If you did not enable it before the 504s started, there is nothing to read yet, so turn it on and reproduce the failure.

_03_Your 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"
```

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

**504 and 502 are different problems**A 502 on an ALB means a connection was made and the reply was wrong, often a keep-alive mismatch. A 504 means no reply arrived in time. The [AWS 502 page](/errors/cdn/aws-502-bad-gateway) covers the first. For the other ALB status in this family, see [ALB 503](/errors/cdn/alb-503).

_05_Explained

## 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](/seo-issues/server-errors-5xx).

Sources · 5

## Every fact, linked and dated.

Official docs first. The date is when we last opened each page.

- amazon.com
- google.com

1. 01 [AWS: Troubleshoot your Application Load Balancers](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-troubleshooting.html) docs.aws.amazon.com · checked 2026-11-01
2. 02 [AWS: Application Load Balancer attributes](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/edit-load-balancer-attributes.html) docs.aws.amazon.com · checked 2026-11-01
3. 03 [AWS: Access logs for your Application Load Balancer](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-access-logs.html) docs.aws.amazon.com · checked 2026-11-01
4. 04 [AWS: Health checks for Application Load Balancer target groups](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/target-group-health-checks.html) docs.aws.amazon.com · checked 2026-11-01
5. 05 [How HTTP status codes affect Google's crawlers](https://developers.google.com/crawling/docs/troubleshooting/http-status-codes) developers.google.com · checked 2026-11-01

Questions

## Asked a lot.

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

_01_ What 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.

_02_ How 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.

_03_ Does 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.

## Keep learning

[All errors](/errors)

[Learn ALB 503 Service Unavailable CDN and hosting errors](/errors/cdn/alb-503) [Related 504 Gateway Timeout HTTP status codes](/errors/http/504) [Read next AWS Lambda 502 Bad Gateway CDN and hosting errors](/errors/cdn/aws-lambda-502) [Do Run a free site audit Free, about two minutes](/site-audit)

Other 504 errors
[504 Gateway Timeout](/errors/http/504) [504 Gateway Timeout in Apache](/errors/http/504/apache) [504 Gateway Timeout on IIS](/errors/http/504/iis) [API Gateway 504 Gateway Timeout](/errors/cdn/api-gateway-504) [Cloudflare 504 Gateway Timeout](/errors/cdn/cloudflare-504)

More AWS errors
[ALB 503 Service Unavailable](/errors/cdn/alb-503)

More in CDN and hosting errors
[Netlify function timeout](/errors/cdn/netlify-function-timeout) [Render 502 Bad Gateway](/errors/cdn/render-502) [S3 Access Denied (403 Forbidden)](/errors/cdn/s3-access-denied) [Vercel 413: FUNCTION_PAYLOAD_TOO_LARGE](/errors/cdn/vercel-payload-too-large) [Vercel 429: Too Many Requests](/errors/cdn/vercel-429) [Vercel 500: Internal Server Error](/errors/cdn/vercel-500) [Vercel build failed](/errors/cdn/vercel-build-failed) [Vercel domain not working](/errors/cdn/vercel-domain-not-working) [Vercel FUNCTION_INVOCATION_TIMEOUT](/errors/cdn/vercel-function-invocation-timeout) [Vercel: too many redirects](/errors/cdn/vercel-too-many-redirects) [Akamai reference number](/errors/cdn/akamai-reference-number) [ALB 503 Service Unavailable](/errors/cdn/alb-503) [ALB 504 Gateway Timeout](/errors/cdn/alb-504-gateway-timeout) [API Gateway 403 Forbidden](/errors/cdn/api-gateway-403-forbidden) [API Gateway 504 Gateway Timeout](/errors/cdn/api-gateway-504) [AWS 502 Bad Gateway](/errors/cdn/aws-502-bad-gateway) [AWS Amplify 404 Not Found](/errors/cdn/amplify-404) [AWS EC2: Connection timed out](/errors/cdn/aws-ec2-connection-timed-out) [AWS Lambda 502 Bad Gateway](/errors/cdn/aws-lambda-502) [AWS Lambda timeout](/errors/cdn/lambda-timeout) [Azure Front Door 502](/errors/cdn/azure-front-door-502) [Cloud Run 503 error](/errors/cdn/cloud-run-503) [Cloudflare 504 Gateway Timeout](/errors/cdn/cloudflare-504) [Cloudflare Pages 404 Not Found](/errors/cdn/cloudflare-pages-404)

Terms on this page
[HTTPS](/glossary/https)

Free · 2 minutes

## Tools point. Agencies advise. _This one ships._

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

[Audit my site free](/site-audit)

Free, no card 60 seconds Nobody will call you

- **46** fixes shipped without a ticket Brightpipe
- **0→7** ChatGPT citations in six weeks Paylane
