.NET Core publish to IIS - HTTP Error 502.3 - Bad Gateway - The specified CGI application encountered an error and the server terminated the process
If you run a task for a long time, and web browser don't receives response in 2 mins(the default request time), you'll get this error. Because after the timeout, IIS will replaces the application to respond to the client with 'Bad Gateway'.
Maybe you should change the request time in the web.config.
Set requestTimeout attribute in section system.webServer / aspNetCore to specifies the duration for which the ASP.NET Core Module will wait for a response from the process listening on %ASPNETCORE_PORT%.
- The requestTimeout must be specified in whole minutes only, otherwise it defaults to 2 minutes.
Just like this:
<system.webServer>
<aspNetCore requestTimeout="00:20:00" ... />
</system.webServer>
How can I debug this? Anyone have any ideas?
Here are three ideas:
Read this and make sure that you have covered all that it says.
Run the published
.\MyApp.exe
from the command line. Does that work?- If it does, you know you have an IIS integration problem.
- If it does not, you know you have an application problem.
Change
stdoutLogEnabled="false"
totrue
and then check the logs atstdoutLogFile=".\logs\stdout"
. The error(s) there might tell you something.Check your IIS Application logs in the Event Viewer. The error(s) there might tell you something.
Event Viewer Application Logs
The solutions did not work for me, but what did is:
Enable web developer mode (press F12 in your browser)=> application tab =>then remove all cookies. Refresh the page and voilà: it works. Also you can copy your URL and paste to another browser you haven't run any MVC project.
My project worked on Internet Explorer and Microsoft Edge without any change. Perhaps that's the cause of your error.