502 - Web server received an invalid response while acting as a gateway or proxy server.

738 Points
154 Posts

I have web-service hosted on Azure. And I'm tried to request an endpoint that has long running process. I'm getting following error after around 2 minutes:

<h2>502 - Web server received an invalid response while acting as a gateway or proxy server.</h2>
  <h3>There is a problem with the page you are looking for, and it cannot be displayed.
When the Web server (while acting as a gateway or proxy) contacted the upstream content server,
it received an invalid response from the content server.</h3>

Any one known what is happening here...

Views: 14065
Total Answered: 3
Total Marked As Answer: 0
Posted On: 29-Mar-2019 02:08

Share:   fb twitter linkedin
 - Akansha yadav  08-May-2020 04:19
206 Points
38 Posts

"502 bad gateway" and "503 service unavailable" are common errors in your app hosted in Azure App Service.

This problem is often caused by application level issues, such as:

  1. requests taking a long time
  2. application using high memory/CPU
  3. application crashing due to an exception.

You need to trouble shoot on above mentioned points.  Troubleshooting can be divided into three distinct tasks, in sequential order:

Observe and monitor application behavior
Collect data
Mitigate the issue

Please follow on https://docs.microsoft.com/en-us/azure/app-service/troubleshoot-http-502-http-503 for more details how to trouble shoot.

Posted On: 30-Mar-2019 00:38
224 Points
52 Posts

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

You can 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

Posted On: 04-Apr-2019 09:41
Akansha yadav
2 Points
1 Posts

One day suddenly on azure app I started to get the error 502 web server received an invalid response while acting as a gateway or proxy server on azure web app.

I did too much research to solve this problem, than I contacted to the support and they given me following solution which works for me.

“Scale up the application to Medium in order to change the instance where your application is running. Wait some minutes and check again your site The above change will change the worker instance.” 

I hope this will help to solve the problem




Posted On: 30-Apr-2020 01:26
 Log In to Chat