ECONNRESET and 502 bad gateway errors

David Cross 20 Reputation points
2025-06-13T22:24:42.1933333+00:00

I am experiencing intermittent errors when connecting to https://northcentralus.tts.speech.microsoft.com/cognitiveservices/v1

Some submissions work and, with the same payload, they are returned with a 502 error or ECONNRESET error.

(The screenshots below are from Make.com's HTTP module.)

Below is the code I am using.

  1. Why these errors?
  2. How can they be prevented?

This is a proof of concept for an app. Azure looked great and is a lot less costly than ElevenLabs but this is unreliable.

Help - I cannot buy a support contract while on a free trial, and I ain't going off the free trial while this fails every 4 or 5 runs.

Thank you

<speak

version="1.0"

xmlns="http://www.w3.org/2001/10/synthesis"

xmlns:mstts="http://www.w3.org/2001/mstts"

xml:lang="en-GB">

<voice name="en-GB-AdaMultilingualNeural">

<prosody rate="0.85">

<mstts:express-as style="calm" styledegree="1.3">

MY TEXT GOES HERE

</mstts:express-as>

</prosody>

</voice>

</speak>

Xnip2025-06-13_14-49-36.png

Xnip2025-06-13_15-11-34.png

Azure AI Speech
Azure AI Speech
An Azure service that integrates speech processing into apps and services.
2,061 questions
0 comments No comments
{count} votes

Accepted answer
  1. Pavankumar Purilla 8,335 Reputation points Microsoft External Staff Moderator
    2025-06-16T02:02:31.4633333+00:00

    Hi David Cross,

    You're encountering intermittent 502 Bad Gateway and ECONNRESET errors while using the Azure Cognitive Services Text-to-Speech (TTS) API, which can be especially frustrating when you're trying to build a proof-of-concept. These errors are typically network-related or service-side issues and can disrupt the smooth functioning of your application.

    The 502 Bad Gateway error generally means that the gateway or proxy server didn’t receive a valid response from the upstream service. This can occur if the Azure TTS service is experiencing internal issues or delays in processing the request. On the other hand, ECONNRESET indicates that the connection was forcibly closed by the remote host. This often points to network interruptions, firewall interference, or a timeout situation where the server drops the connection unexpectedly.

    There are a few common causes for these kinds of errors. Firstly, the health of the Azure service itself can be a factor—there may be brief downtimes or capacity-related slowdowns in certain regions. Secondly, rate limiting might be affecting your requests; if you're sending too many requests in a short span, the service might throttle or drop some of them.
    Lastly, your local or intermediate network environment might also contribute to connection resets—this could include VPNs, proxies, or firewalls blocking or altering traffic.

    To mitigate these issues, you should implement retry logic with exponential backoff in your code. When a request fails with a 502 or ECONNRESET, wait a short time and try again—this is often enough to bypass transient issues. Also, implement logging and monitoring around your API calls to track when and how often these errors occur, including logging the request body, headers, and timestamps. Additionally, review your network setup to make sure nothing is interfering with outgoing traffic to Azure services.

    For more information:


0 additional answers

Sort by: Most helpful

Your answer

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