Share via

API requests error Client.Timeout exceeded while awaiting headers

Nikolai Tyumin 0 Reputation points
2026-03-31T11:26:34.2266667+00:00

Good afternoon.

I am testing Azure services for network throughput from various locations (Kazakhstan, Kyrgyzstan, Russia, the United States, and Brazil). I purchased a virtual machine running Windows Server and deployed my front-end and back-end applications on it. The virtual machine is used as a web server. Using test programs, I send API requests to the backend application, and I also open and periodically refresh the frontend application’s home page in the browser. I’m getting poor results from all locations where requests are sent. I get a 500 error and the error “context deadline exceeded (Client.Timeout exceeded while awaiting headers)” for API requests. I also get these errors almost immediately if I send a large number of requests.

I’ve also noticed that when opening the application’s website from Russia, loading the frontend’s static resources takes a long time—between 7 and 12 seconds. In Europe, it takes tens of milliseconds.

I’d like to know if there might be any network restrictions and how they can be resolved?

Azure Virtual Network
Azure Virtual Network

An Azure networking service that is used to provision private networks and optionally to connect to on-premises datacenters.


3 answers

Sort by: Most helpful
  1. Ganesh Patapati 11,760 Reputation points Microsoft External Staff Moderator
    2026-04-07T04:48:21.92+00:00

    Hello Nikolai Tyumin

    it sounds like you’re seeing high latency and timeouts (“context deadline exceeded”) when hitting your API and serving static content from your single Azure VM across the globe. A few things can throttle traffic or add latency:

    There are no hidden Azure network restrictions impacting your application. The observed errors are due to expected global latency and a single-VM architecture without edge delivery. Microsoft documentation explicitly recommends CDN/Front Door and horizontal scaling to address these scenarios.

    1. VM network bandwidth limits • Every VM SKU has a maximum network throughput (e.g. 500 Mbps, 1 Gbps, etc.). If you’re on a smaller SKU (B-series, A-series), you’ll see limited throughput and throttling under load.
    2. Check your VM size/series and compare against the published network bandwidth limits: https://learn.microsoft.com/azure/virtual-machines/sizes
    3. Use Azure Network Watcher Connection Troubleshoot to validate connectivity and latency: https://learn.microsoft.com/azure/network-watcher/network-watcher-check-connectivity
    4. Windows Server’s built-in firewall or connection limits might be set too low for high-concurrency tests. Verify inbound rules and maximize half-open connections if you’re doing massive concurrent calls.
    5. A single VM in one Azure region will naturally have hundreds of milliseconds of round-trip to distant locations. • For static assets, front them via Azure CDN or Front Door to cache them at POPs closer to your users: https://learn.microsoft.com/azure/cdn/
    6. For your API, consider deploying additional instances in regions closer to your traffic using Traffic Manager or Front Door so your clients hit the nearest endpoint.
    7. Under heavy load, your app may exhaust CPU, memory, or ephemeral ports, causing 500 errors and timeouts. Monitor VM metrics in Azure Monitor and scale out to a VM Scale Set behind a Load Balancer if needed: https://learn.microsoft.com/azure/virtual-machine-scale-sets/

    Should there be any follow-up questions or concerns, please let us know and we shall try to address them.

    If these answer your question, click "Upvote" and click "Accept Answer" which may be beneficial to other community members reading this thread.

    0 comments No comments

  2. Yutaka_K_JP 1,645 Reputation points
    2026-03-31T15:53:34.5833333+00:00

    The issue isn’t geo … it’s ur VM’s recv‑path stalling on long hops, so curl -I once from a tiny same‑region VM — if that snaps back fast, push static bits to CDN and bump backend conn/keepalive limits; if still slow, check irq spread + rx‑ring depth.

    0 comments No comments

  3. Q&A Assist
    2026-03-31T11:27:04.0966667+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    The symptoms described (HTTP 500 errors, Client.Timeout exceeded while awaiting headers, and much slower responses or timeouts when sending many requests) are consistent with backend or platform-side timeouts and/or connection exhaustion, not with a simple “hard” network block.

    From the provided information, the following Azure-related behaviors are relevant:

    1. Backend / load balancer timeouts
      • Azure Load Balancer and services that sit behind it have default idle/request timeouts. For example, in Azure App Service a web request that doesn’t complete within ~230–240 seconds is terminated and returned as a timeout to the client.
      • Application Gateway has a configurable backend request timeout (20 seconds by default). If the backend doesn’t respond within that interval, it returns 502/504 errors.
      • If the backend application on the VM is slow, blocked, or overloaded, these platform timeouts can surface as client-side context deadline exceeded or HTTP 5xx errors.
      If an Application Gateway or similar component is in front of the VM, ensure the backend timeout is set appropriately for the workload and that the backend is healthy and responsive.
    2. SNAT port exhaustion and intermittent 5xx/timeouts
      • When Azure services make outbound connections (for example, from an App Service or API Management instance to a backend), they rely on a finite pool of SNAT ports per instance.
      • A rapid succession of client requests to the same host/port can exhaust the SNAT port quota if connections are not closed and recycled fast enough. This leads to:
        • Intermittent HTTP 500/5xx errors
        • Time-out error messages
        • BackendConnectionFailure-type failures in logs
      • Similar behavior is documented for both Azure API Management and Azure App Service: slow responses, intermittent 5xx, and timeouts when SNAT ports are exhausted.
      If the test setup involves an Azure service (App Service, API Management, Functions, etc.) calling the VM or another external endpoint, high request rates can trigger SNAT exhaustion. In that case, mitigation options include:
      • Reducing connection churn (connection pooling, keep-alive)
      • Throttling or rate limiting spikes (for example, using API Management rate-limit policies)
      • Scaling out instances so that more SNAT ports are available
    3. High load and resource saturation on the VM / web stack
      • Even if there is no explicit Azure network restriction, the VM or web server can become CPU- or connection-bound under heavy load, causing:
        • Slow responses (seconds instead of milliseconds)
        • Timeouts on the client side
        • HTTP 500 errors from the application or reverse proxy
      • In App Service scenarios, high CPU and memory usage across many sites or processes can cause slow responses and timeouts; the recommended mitigations are to scale up or split workloads into separate plans.
      On a self-managed VM, similar principles apply: monitor CPU, memory, and connection counts; ensure the web server and application are tuned for the expected concurrency; and scale up or out if needed.
    4. Regional performance differences (Russia vs Europe)
      • The much higher latency and long load times from Russia compared to Europe are consistent with general internet routing and peering differences rather than a specific Azure configuration on the VM. Azure does not guarantee identical performance from all global locations to a single region.
      • To improve global performance, typical approaches include:
        • Placing workloads closer to users (deploying in additional regions)
        • Using a global front door, CDN, or caching layer to serve static assets closer to clients
    5. How to proceed with troubleshooting Based on the context:
      • Check for timeouts and 5xx patterns in any Azure fronting service (Application Gateway, API Management, App Service) and adjust request timeouts if applicable.
      • If an Azure service is calling the backend, review for SNAT port exhaustion symptoms (intermittent 5xx/timeouts under high request rates) and apply mitigations such as rate limiting, caching, or scaling out.
      • On the VM, monitor resource usage and web server logs during load tests to confirm whether the application or OS is the bottleneck.
      • For long-running operations, avoid keeping HTTP requests open for extended periods; instead, offload to background processing and return quicker responses where possible.

    There is no indication in the provided material of a specific Azure “network restriction” that would selectively block or throttle traffic from the listed countries. The behavior aligns more with timeouts, backend performance limits, and connection/SNAT exhaustion under load.


    References:

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.