API Request Timeout - Endpoint Takes Too Long
API requests timeout while waiting for response. Frontend gets 'fetch timeout' error or 504 error.
The endpoint works but is slow. Same endpoint sometimes works, sometimes doesn't.
Error Messages You Might See
Common Causes
- Endpoint performs heavy computation without optimization
- Database query not optimized - missing indexes or fetching too much data
- External API calls not having timeouts or being slow
- Request waiting for previous long-running requests to complete
- Timeout set too low for legitimate request duration
How to Fix It
Set fetch timeout: fetch(url, { timeout: 30000 }) for 30 second timeout
Optimize queries: add database indexes, use pagination for large results
Add timeout to external calls: fetch(externalUrl, { timeout: 5000 })
Move long tasks to background jobs, return response immediately
Monitor endpoint: track execution time, profile bottlenecks
Real developers can help you.
You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.
Get HelpFrequently Asked Questions
What's a good timeout for API calls?
Client-side: 30s max. For database: 5-10s depending on complexity. External APIs: 10-15s
How do I handle slow endpoints?
1) Optimize the query/logic, 2) Use background jobs for long tasks, 3) Increase timeout, 4) Implement pagination
Should I retry on timeout?
Sometimes. For idempotent endpoints (GET, DELETE with same ID) yes. For POST/mutations, be careful of duplicates