An Azure service that provides an event-driven serverless compute platform.
Hi @Samuel Tomko ,
Thanks for reaching out to Microsoft Q&A.
"502 bad gateway: upstream connect error or disconnect/reset before headers. retried and the latest reset reason: protocol error"
This error means the gateway isn’t able to successfully connect or keep a healthy TCP/HTTPS session with your backend.
Here are some troubleshooting steps you can try:
- Check Backend Health in App Gateway
- In the Azure Portal, go to your Application Gateway → Backend health.
- If you see failing probes, no healthy instances = 502.
- Validate Health Probe Configuration
- By default App Gateway probes the root (“/”) with GET. If your SCIM endpoint is at, say,
/scim/Healthor requires a specific header, configure a custom probe to hit that path and expect a 200. - Ensure the probe uses the correct protocol (HTTP vs HTTPS), port, and host name.
- By default App Gateway probes the root (“/”) with GET. If your SCIM endpoint is at, say,
- Review NSG / UDR / DNS Settings
- If your AGW sits in a VNet, make sure any NSGs or User-Defined Routes aren’t blocking outbound to your Function App (especially if you’re using VNet Integration).
- If you use a custom DNS in the VNet, confirm it correctly resolves your Function’s FQDN.
- Check TLS / Protocol Compatibility
- A “protocol error” reset often indicates a TLS mismatch.
- Ensure your Function App supports TLS 1.2 (App Gateway v2 doesn’t support TLS 1.3 yet).
- If you require client certs or unusual ciphers, verify App Gateway supports them.
- Increase Backend HTTP Settings Timeout
- The default request timeout is 20 seconds (v1) or it retries on a second backend (v2). If your SCIM calls occasionally take longer, bump the timeout:
New-AzApplicationGatewayBackendHttpSettings … ‑RequestTimeout 60
- Confirm Backend Address Pool Configuration
- Make sure your Function’s host/IP or FQDN is correctly listed in the backend pool and that it’s not empty.
- Scale Considerations
- If you’re seeing these errors under load, your AGW tier/instance count might be insufficient. Consider scaling up/out or adding alerts for high request counts.
- Enable and Analyze Logs
- Turn on Application Gateway Access logs and Firewall logs (if WAF is enabled).
- Look for “502” entries and see if the reset reason shows up in the logs. This gives you insight into whether it’s a probe failure, network block, or protocol drop.
Hope this helps!
If the resolution was helpful, kindly take a moment to click on and click on Yes for was this answer helpful. And, if you have any further query do let us know.