# HTTP 504 Deadline Exceeded: upstream request timeout after 60s while waiting for Cloud Run container to start

- **ID:** `cloud/gcp-cloud-run-cold-start-http-timeout`
- **Domain:** cloud
- **Category:** runtime_error
- **Error Code:** `504`
- **Verification:** ai_generated
- **Fix Rate:** 82%

## Root Cause

Cloud Run cold start latency exceeded the 60-second HTTP load balancer timeout because the container image is large or the application initialization is slow.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Cloud Run managed platform (gcloud CLI 450.0.0) | active | — | — |
| Cloud Run for Anthos 1.28 | active | — | — |
| Google Cloud SDK 450.0.0 | active | — | — |

## Workarounds

1. **Reduce container image size by using a slim base image (e.g., 'alpine' instead of 'ubuntu') and removing build dependencies. For Node.js apps, run 'npm prune --production' before building the image.** (75% success)
   ```
   Reduce container image size by using a slim base image (e.g., 'alpine' instead of 'ubuntu') and removing build dependencies. For Node.js apps, run 'npm prune --production' before building the image.
   ```
2. **Enable min-instances for Cloud Run to keep at least one instance warm: 'gcloud run services update SERVICE --min-instances=1'. This eliminates cold starts for most requests.** (95% success)
   ```
   Enable min-instances for Cloud Run to keep at least one instance warm: 'gcloud run services update SERVICE --min-instances=1'. This eliminates cold starts for most requests.
   ```

## Dead Ends

- **** — Larger resources do not reduce cold start time; they only affect runtime performance. Cold start is dominated by image download and app startup. (95% fail)
- **** — Startup CPU boost only helps during the startup probe period, not the initial HTTP request timeout. The 504 occurs before the probe even begins. (80% fail)
