Insights AI News How to increase third-party request timeout to avoid errors
post

AI News

11 Jun 2026

Read 10 min

How to increase third-party request timeout to avoid errors

Increase third-party request timeout to prevent 500 errors and keep external content loading reliably.

You can increase third-party request timeout by setting it at every hop: your HTTP client, any proxy or gateway, and the upstream service. Choose values from real latency data. Add retries with backoff and a hard cap. If a platform blocks longer waits, push slow work to a queue and return an async response. A timeout error means your app waited too long for a partner API or asset. Some services let you pass a timeout in the URL, like “?timeout=50000&url=…”, which sets the wait in milliseconds. Others need a config change in your HTTP client, proxy, or server. The steps below show where and how to adjust safely.

Why timeouts happen

  • Network delay: Cold starts, DNS, TLS, or slow links add seconds.
  • Upstream load: The third-party API is busy or rate-limiting you.
  • Proxy limits: Gateways, CDNs, or load balancers cap request time.
  • Platform caps: Serverless and API gateways often limit to 10–30 seconds.
  • Bad defaults: Clients may have no timeout or a very low one.
  • How to increase third-party request timeout safely

    1) Set the timeout in your client

  • Browser fetch: Use AbortController and a timer to cancel after N ms. The browser does not have a default timeout, so you must add one.
  • Axios (Node or browser): “axios.get(url, { timeout: 50000 })”. This sets a total request timeout.
  • Node core https: “req.setTimeout(50000)” and handle the timeout event.
  • Got: “got(url, { timeout: { request: 50000, connect: 3000 } })”. Use a smaller connect timeout and a larger read timeout.
  • cURL: “curl –max-time 50 ‘https://proxy.example.com?timeout=50000&url=…’”. This caps the whole transfer at 50 seconds.
  • Proxy URL parameter: If your proxy supports it, adding “timeout=50000” can increase third-party request timeout without code changes. Validate and clamp this on the server to prevent abuse.
  • Tips
  • Separate connect and read timeouts. Example: connect 2–5s, read 15–60s.
  • Pass a deadline. Compute “now + budget” and forward it in a header, like “X-Request-Deadline”. Downstream services can stop work when time runs out.
  • Add retries with exponential backoff and jitter. Retry only safe, idempotent methods (GET, PUT with idempotency keys).
  • 2) Tune your proxy or gateway

  • Nginx: Set “proxy_connect_timeout”, “proxy_send_timeout”, and “proxy_read_timeout” to your budget (for example, 60s). Ensure “keepalive” is on for upstreams.
  • Apache HTTPD: Use “ProxyTimeout 60” or per-virtual-host settings.
  • HAProxy: Tune “timeout connect”, “timeout client”, and “timeout server”. Match your client budget plus a small cushion.
  • CDNs and edge: Many have hard limits (for example, 100 seconds on some plans). You cannot exceed these. Stream if possible, or move to async.
  • API Gateway: AWS API Gateway HTTP/REST has a ~29–30s max to clients. You cannot increase this. Use a queue pattern for longer tasks.
  • Raising proxy limits without changing the client does not help if the client cancels first. Update both ends.

    3) Configure the upstream service

  • Serverless timeouts: Increase the function timeout (for example, AWS Lambda up to 15 minutes), but remember the front-door cap (API Gateway ~30s). Split long jobs: return 202 Accepted and process in the background.
  • Application server: Raise request timeout, thread or worker limits, and queue sizes with care. Monitor saturation.
  • Database and downstream calls: Set query and connection timeouts so the service can fail fast instead of holding the socket open.
  • Memory and CPU: More resources often reduce long tails and avoid timeouts.
  • 4) When you cannot wait longer, change the pattern

  • Async job + polling: Enqueue the job, return a task ID, and let the client poll or use webhooks or Server-Sent Events.
  • Streaming: Send partial results as they arrive so the connection stays active.
  • Caching: Cache stable responses to avoid repeated slow calls.
  • Fallbacks: Serve a cached or simplified answer if the upstream is slow.
  • Pick the right numbers

  • Use data. Look at p95 and p99 latency from logs. Set the timeout just above your p99, not 10x higher.
  • Budget per hop. Example: 30s total = 3s DNS/TLS/Connect + 22s upstream read + 5s cushion.
  • Different routes, different budgets. Search can be 5–10s. Exports can be async.
  • Protect yourself. Add a global ceiling so user requests never hang forever.
  • Sample starting points (adjust with data)
  • Connect timeout: 2–5 seconds
  • Read timeout: 15–60 seconds
  • Total user request deadline: 10–30 seconds for interactive paths
  • Test and monitor

  • Simulate delay. Inject latency and errors in staging to confirm your timeouts, retries, and fallbacks work.
  • Track outcomes. Count successes, timeouts, and retries. Watch p95/p99, saturation, and error budgets.
  • Alert on symptoms. Fire alerts on rising timeouts, not just total errors.
  • Log reasons. Log whether the client, proxy, or upstream hit the timeout. Add correlation IDs across hops.
  • Common pitfalls to avoid

  • Only changing one layer. You must align client, proxy, and service timeouts.
  • Setting timeouts too high. Very long waits can waste threads and money and hurt users. Prefer async for long tasks.
  • No idempotency. Retries can duplicate work without idempotency keys.
  • No cancellation. Use deadlines to stop downstream work once the client gives up.
  • Ignoring platform caps. Some limits (for example, 30s API Gateway) cannot be bypassed.
  • Quick checklist

  • Define a per-route time budget from latency data.
  • Set client connect and read timeouts to fit that budget.
  • Align proxy and gateway timeouts slightly above client values.
  • Increase upstream service and database timeouts within reason.
  • Add exponential backoff, jitter, and idempotency keys.
  • Implement async flow for tasks that exceed platform limits.
  • Instrument, test with injected delay, and monitor p95/p99.
  • Strong systems do not only increase third-party request timeout. They also bound work, retry safely, and fall back when the network is slow. Use data to set the right values, align every hop, and move long jobs to async paths. With these steps, you can increase third-party request timeout without hurting user experience or cost.

    (Source: https://www.bloomberg.com/news/articles/2026-06-07/starmer-to-roll-out-uk-job-center-tools-to-beat-ai-work-threat)

    For more news: Click Here

    FAQ

    Q: What does the “Request of third-party content timed out” error mean? A: A timeout error means your app waited too long for a partner API or asset. Some services let you pass a timeout in the URL like “?timeout=50000&url=…” which sets the wait in milliseconds. To avoid this, you can increase third-party request timeout by setting timeouts across client, proxies, and upstream services. Q: Where should I change settings to increase third-party request timeout? A: To increase third-party request timeout, set timeouts at every hop: your HTTP client, any proxy or gateway, and the upstream service. Choose values from real latency data and add retries with exponential backoff and a hard cap. Q: How do I choose appropriate timeout values? A: Use real latency metrics such as p95 and p99 from logs and set the timeout just above your p99 rather than arbitrarily higher. Budget per hop—for example a 30s total budget might be 3s for DNS/TLS/connect, ~22s for upstream read, and a 5s cushion—and consider starting points like connect 2–5s and read 15–60s. Q: What should I do if my platform enforces a hard timeout limit? A: If a platform blocks longer waits (for example API Gateway HTTP/REST with a ~29–30s max), push slow work to a queue and return an asynchronous response such as 202 Accepted. Alternatives include streaming partial results, caching, or serving a fallback when the upstream is slow. Q: How do I tune proxies or API gateways to allow longer waits? A: Tune proxy settings such as nginx’s proxy_connect_timeout, proxy_send_timeout, and proxy_read_timeout to match your budget and ensure keepalive is enabled for upstreams. Align gateway and proxy timeouts slightly above client values and be aware some CDNs and edge platforms have hard limits you cannot exceed. Q: How should I test and monitor changes after I increase third-party request timeout? A: Simulate delay and inject latency and errors in staging to confirm your timeouts, retries, and fallbacks work as expected. Track p95/p99, count successes, timeouts, and retries, log whether the client, proxy, or upstream hit the timeout, and use correlation IDs across hops for diagnosis. Q: What are common pitfalls to avoid when I increase third-party request timeout? A: Common pitfalls include changing only one layer while leaving others unchanged, setting timeouts too high which wastes threads and money, and ignoring platform caps that cannot be bypassed. Also avoid retrying non-idempotent operations without idempotency keys and failing to use deadlines to cancel downstream work once the client gives up. Q: Should I add retries when increasing third-party request timeout, and how should I implement them? A: Add retries with exponential backoff and jitter and only retry safe, idempotent methods such as GET or PUT with idempotency keys. Also implement a hard cap and forward a deadline header like X-Request-Deadline so downstream services can stop work when time runs out.

    Contents