Frequent 504 Gateway Timeout errors from api.anthropic.com
Description
Experiencing frequent and random 504 Gateway Timeout errors when using Claude Code, which significantly impacts productivity.
Error Details
API Error (api.anthropic.com | 504: Gateway time-out) · Retrying in 5 seconds… (attempt 4/10)
⎿ API Error (api.anthropic.com | 504: Gateway time-out) · Retrying in 9 seconds… (attempt 5/10)
⎿ API Error (api.anthropic.com | 504: Gateway time-out) · Retrying in 16 seconds… (attempt 6/10)
⎿ API Error (api.anthropic.com | 504: Gateway time-out) · Retrying in 35 seconds… (attempt 7/10)
⎿ API Error (api.anthropic.com | 504: Gateway time-out) · Retrying in 34 seconds… (attempt 8/10)
I'm now having difficulty recovering my session, even after the agent responded:
<img width="965" height="380" alt="Image" src="https://github.com/user-attachments/assets/2b37139f-2b45-4ee0-9f45-4c647f9f8672" />
Frequency
These errors occur randomly during normal usage, often requiring multiple retry attempts before succeeding.
Impact
- Interrupts workflow
- Causes delays in development
- Sometimes requires 8+ retry attempts
Environment
- Claude Code CLI
- Platform: macOS (Darwin 23.5.0)
- Date observed: 2025-08-29
Expected Behavior
API calls should complete successfully without frequent gateway timeouts.
Additional Context
The retry mechanism does eventually succeed in most cases, but the frequency of these errors suggests there may be an infrastructure or rate limiting issue that needs investigation.
Workaround:
I was able to recover my session task by asking the agent to break out the output file into seperate smaller files.
<img width="1362" height="200" alt="Image" src="https://github.com/user-attachments/assets/2ba8c65f-be5a-4ec5-a251-261ab33bb20c" />
I got it to write one file, but now it's stuck again:
<img width="612" height="53" alt="Image" src="https://github.com/user-attachments/assets/bf1940c4-9830-4819-9088-06374cc6d538" />
Here's a screenshot of my current context usage for whomever at anthropic works on debugging this issue:
<img width="846" height="280" alt="Image" src="https://github.com/user-attachments/assets/69dc97e5-19e0-4e7c-8b7a-e3dc2c3191f6" />
This issue has 14 comments on GitHub. Read the full discussion on GitHub ↗