The 504 at second 60
Generating a long AI report works on your laptop. In production, where the route's time limit is set to 60 seconds, big reports fail with '504 Gateway Timeout'.
This answers: Why do I get a 504 timeout only in production? No coding needed. 2 quick decisions.
- How a request travels
- Costs and abuse
Checking your access…
Why do I get a 504 timeout only in production?
Hosted functions stop at a set time limit, while your laptop has none. Long AI calls, imports or file processing exceed it and return 504 Gateway Timeout. Streaming improves the wait but still counts toward the limit; move long tasks to a that reports progress.
Breaks at Your server: Stopped at the 60-second limit
How it works
2xx
It worked
200 OK · 201 Created · 204 No Content
4xx
The request was wrong or not allowed
400 Bad request · 401 Not signed in · 403 Not allowed · 404 Not found · 413 Too large · 429 Too many
5xx
The server broke
500 Server error · 504 Timed out
Why AI tools write this bug
Generated code usually does all the work inside one request, which is fine locally and breaks the first time production work takes longer than the limit.
How to fix it
- Check the duration in the logs; a round number means a limit.
3 more steps, and a prompt that checks your own app for this bug. Part of Pro.
UnlockCommon questions
- Should I just raise the timeout?
- Sometimes it helps, but long work in one request is fragile. Background jobs scale better.