Azure 502 Bad Gateway Issue

Mohammed Shafi 65 Reputation points
2025-01-15T15:23:59.74+00:00

I use an application gateway with WAF setup to run our web application deployed in a single Azure VM.

When I access the application through App GW from the browser, I sometimes get a 502 Bad Gateway error. The App GW health probe responds with, "Cannot connect to backend server. Check whether any NSG/UDR/Firewall is blocking access to the server. Check if application is running on correct port."

This issue does not always occur. Whenever I hit the server multiple times, this issue occurs, and it will fix itself automatically after some time or if I clear the browser cache.

In App GW log, I get sometime "error_info_s: ERRORINFO_UPSTREAM_NO_LIVE" or "ERRORINFO_UPSTREAM_CLOSED_CONNECTION".

Is this behaviour of App GW or any solution to fix the issue.? Appreciate your suggestions or sharing your experiences.

Bknd_health

Bknd_health_success

Connectivity Details When Error Occure

Azure Application Gateway
Azure Application Gateway
An Azure service that provides a platform-managed, scalable, and highly available application delivery controller as a service.
1,131 questions
{count} votes

Accepted answer
  1. KapilAnanth-MSFT 48,771 Reputation points Microsoft Employee
    2025-02-10T11:20:55.3433333+00:00

    @Mohammed Shafi ,

    Welcome to the Microsoft Q&A Platform. Thank you for reaching out & I hope you are doing well.

    Per your latest comment, I see you were able to resolve the issue.

    Issue :

    • You have a VM acting as backend of Application Gateway
    • You are receiving 502 Bad Gateway intermittently
    • The App gateway access logs, and you see errors "ERRORINFO_UPSTREAM_NO_LIVE" and "ERRORINFO_UPSTREAM_CLOSED_CONNECTION" (which belong to App Gw 5XX Errors)
    • You informed NSG Rules are allowed and there is no UDR configured, issue remains even with Local OS Firewall is disabled.

    Solution :

    • You found that the missing SSL certificate chain caused this issue.
    • You had revoked and replaced it with another open-source SSL certificate with a full bundle for testing, which worked as expected.

    Kindly let us know if you need further assistance on this issue.

    Thanks,

    Kapil


    Please don’t forget to close the thread by clicking "Accept the answer" wherever the information provided helps you, as this can be beneficial to other community members.

    0 comments No comments

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.