The specified CGI application encountered an error and the server terminated the process
Asked Answered
B

11

32

I am hosting a asp.net 5 application on azure, the code is complied for beta8, the application runs fine on the local environment and when i publish the code on the azure site. i get a common error "The specified CGI application encountered an error and the server terminated the process."

Burglarize answered 11/11, 2015 at 6:19 Comment(1)
I had this problem with an Azure app service. MS Support said "There was worker instance movement event, 204 switched to 211, due to platform upgrade". Restarting the app service fixed the issue.Quench
G
17

I was able to solve this issue by removing forwardWindowsAuthToken from the web.config file under wwwroot.

  1. Navigate to src/ProjectName/wwwroot
  2. Open the web.config
  3. In the httpPlatformremove the forwardWindowsAuthToken="true/false" property

Redeploy and mine worked fine.

See here https://github.com/aspnet/Hosting/issues/364 for plenty of discussion

Giesecke answered 12/11, 2015 at 13:12 Comment(0)
E
11

Short Answer

For us the fix was to to UseIISIntegration() on the WebHostBuilder.

public static void Main(string[] args)
{
    var host = new WebHostBuilder()
        .UseContentRoot(Directory.GetCurrentDirectory())
        .UseKestrel()
        .UseIISIntegration() // Necessary for Azure.
        .UseStartup<Program>()
        .Build();

     host.Run();
}

More Details

Our web.config looks like this:

<?xml version="1.0" encoding="utf-8"?>         
<configuration>                                
<system.webServer>                             
    <handlers>                                 
    <add name="aspNetCore"                     
        path="*"                               
        verb="*"                               
        modules="AspNetCoreModule"             
        resourceType="Unspecified"/>           
    </handlers>                                
    <aspNetCore processPath="%LAUNCHER_PATH%"  
        arguments="%LAUNCHER_ARGS%"            
        stdoutLogEnabled="false"               
        stdoutLogFile=".\logs\stdout"          
        forwardWindowsAuthToken="false"/>      
</system.webServer>                            
</configuration>       

Our project.json looks like this:

{
  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.0",
      "type": "platform"
    },
    "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0-*",
    "Microsoft.AspNetCore.Server.Kestrel": "1.1.0-*"
  },
  "tools": {
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
  },
  "frameworks": {
    "netcoreapp1.0": {}
  },
  "buildOptions": {
    "emitEntryPoint": true
  },
  "publishOptions": {
    "include": [
      "web.config"
    ]
  },
  "scripts": {
    "postpublish": [
      "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%"
    ]
  }
}

Our nuget.config looks like this:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="AspNetVNext" value="https://www.myget.org/F/aspnetcidev/api/v3/index.json" />
    <add key="NuGet" value="https://api.nuget.org/v3/index.json" />
  </packageSources>
</configuration>
Evilminded answered 11/7, 2016 at 16:49 Comment(1)
when the server was taking too long to respond while doing some slow operation I was getting the same error even in localhost, then I added the "UseIISIntegration" and it did work. thanksNaturism
A
8

This can also happen if you have an infinite loop in your code.

Alexio answered 17/4, 2018 at 19:10 Comment(2)
Happened to me as well, there was a recursive infinite call. It doesn't log anything, and the app just restarts.Younts
Totally agree, all the other solutions here involves to "redeploy" which is basically cleaning the issue, not a real solution. But what I understand can reproduce the issue is an infinite loop on which you consume more resources than expected from your plan.Ferreby
C
5

I recently had the same issue and was able to solve it by setting the requestTimeout within the web.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath=".\PROJECT.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" requestTimeout="00:30:00"/>
    </system.webServer>
  </location>
</configuration>
Candice answered 3/5, 2019 at 14:22 Comment(2)
I'm recommending following the above approach first. It's works for me perfectly.Initiatory
Thank you, I realize that adding the "requestTimeout" bit worked as you suggested.Madras
U
4

I just ran into this error whilst deploying an ASP.core app using .NET 5.4.2. The fix was to deploy to a fresh app service instance. My guess was that there was some junk left lying around from a previous deployment which used a different framework version.

Unpile answered 2/8, 2016 at 13:53 Comment(2)
This worked for me. But instead of recreating a fresh Appservice I connected on the "dirty" existing one through FTP, deleted all the wwwroot content and republished the app.Negron
Another option along these lines, which worked for me, is to scale the app service plan up and then back down. It moves you to new infrastructure without needing to scrap the original app service.Haplo
I
3

I was facing the same issue following are steps how I resolved.

  • My application was .NET CORE 2.2 and I was deploying in the Azure web app.
  • Right Click on the project and click on the publish button.
  • Select the publish profile which you downloaded from Azure.
  • Next, change the deployment mode under Summary to Self-Contained.
  • Now click on publish button it should work. enter image description here
Ilmenite answered 12/6, 2019 at 7:33 Comment(2)
Any info as to why Self-Contained mode fixes this?Imaginal
It copies the corresponding .NET framework files to the server. Most likely it ensured that the expected version was available.Zebrass
I
1

Today we had the same problem. In our case it was caused by a failing Debug.Assert(...).

Iconography answered 3/11, 2020 at 8:8 Comment(1)
Lesson learned: dotnet publish does not take the Release configuration by default. Needs to be dotnet publish -c Release.Iconography
F
0

I have this problem in the azure app service, since the version of asp.net core is preview version, so I update the asp.net core version by NuGet to 2.0.1 and redeploy the app.

The app works again.

Fer answered 23/2, 2018 at 2:9 Comment(0)
F
0

I'm using .NET Core 2.1 and EF Core deployed to an Azure web app. I got this error when I switched from using a database account with db owner rights to a limited database account. I suspect EF needs a right I'm missing when the app starts.

Farfamed answered 6/10, 2018 at 14:23 Comment(0)
C
0

I got the same error. After searching some solutions, I changed the code, replacing the async method calls with non-async ones, regarding the notes that thread pool might exceed the allowed capacity. This did not work. Then I increased the request timeout in web.config to 20 minutes and it is resolved.

Add the string below in web.config file.

requestTimeout="00:20:00"

as

<aspNetCore processPath="dotnet" arguments=".\API.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" requestTimeout="00:20:00" />
Cachucha answered 14/4, 2020 at 8:32 Comment(0)
I
-2

For us its not related with code, appservice redeploy and then restart needs to be done

Idea answered 27/11, 2020 at 16:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.