Increase request timeout of ASP.NET Core API hosted in Azure App Service

If you are using ASP.NET Core 2.0 API and deploying to an Azure App Service, and if the process takes more than 2 minutes, then you will get 502 Bad Gateway response with the message "The specified CGI application encountered an error and the server terminated the process".

You can fix this by adding web.config file to your project -> uncomment <system.webServer> block and add requestTimeout="00:20:00" as shown below

<?xml version="1.0" encoding="utf-8"?>
  <!-- To customize the core module uncomment and edit the following section. 
  For more info see -->
      <remove name="aspNetCore"/>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
    <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" requestTimeout="00:20:00"/>

Happy Coding  😊!!


    Blogger Comment
    Facebook Comment


  1. First tell how to add a web.config file in the project/solution. Asp.Net Core add appsettings.json by default and not web.config. :)

    1. We can add web.config to .Net core project by right click on project -> Click on Add -> New Item -> Web -> Web Configuration File. :)