18

I'm trying to host an azure website and tried troubleshooting for a few hours, but still keep getting the same error 502 Web server received an invalid response while acting as a gateway or proxy server.

I tried enabling logging errors on azure, but all it gives me are 404 not found errorssee error log

dreftymac
  • 31,404
  • 26
  • 119
  • 182
Riz
  • 6,486
  • 19
  • 66
  • 106

4 Answers4

22

502 errors won't be visible in your IIS logs because they are returned by the front end server which basically fowards the requests to the worker hosting your site and there are many reasons why the front end can return 502 error.

Please follow https://azure.microsoft.com/en-in/documentation/articles/app-service-web-troubleshoot-http-502-http-503/ to troubleshoot the issue and see if you can identify which one you are running into

Puneet Gupta
  • 2,237
  • 13
  • 17
  • I have same case but using Azure Portal. Resolution: Login to Azure Portal Go to your App Service Select your App Service Name Select TLS/SSL Settings Click Binding Under TLS/SSL Bindings, click the hostname Under Private Certificate Thumbprint, select non-expired cert and save and test your application. – donubas Jan 30 '20 at 08:05
  • Hi @donubas i dont find that non-expired cert in my case.. could you please help me to do that ? – Mohammad Wasim Khan Jan 11 '21 at 08:06
2

I had a setup with web servers behind a azure application gateway, some servers works properly and traffic to one of the server is having the 502 issue. So I take the following steps:

  1. Check the Backend health on the application gateway, the server can't be reached.
  2. Open the backend server url on a cloud VM http://hostname, the root website can't be reached. But the http://hostname/app is running. It turns out the gateway will ping the port 80 of the target machine and somehow I disabled the root website on the target server. So the gateway assumes the server is dead and refused to do the redirect.
Hainan Zhao
  • 1,962
  • 19
  • 19
1

We were getting a 502 response with an Azure function. The Function App was started, and all of our functions inside here were marked as "good". But when we checked the azure function process explorer, there were no java proceses (this was written in java... pity me)

When checking the Azure function logs, it turned out that someone had deployed a dynatrace integration and this was crashing the function on startup.

So 502 basically means "I can see you are triggering me but when I try to pass that trigger back to the actual function app, I can't see anything"

Nick.Mc
  • 18,304
  • 6
  • 61
  • 91
0

In my case something removed randomly the stack settings of my web app. Check your resource (web app or function app, etc) configuration and confirm that everything is correct.

Azure will restart your application automatically after your changes and you can try a new release after that.