Unable to run my .net core app in local as well as on server with IIS


I created a .net core api (version 2.2.0) and I'm getting the following error when I try to run on IIS.

The application process failed to start The application process started but then stopped The application process started but failed to listen on the configured port

I verified my web config and it appears to have correct set of values.Enabled logging and log file comes as empty.

Event log shows the following error.

enter image description here

I installed hosting bundle and checked still getting same error. Also tried giving permission to IIS_IUSRS to the output folder. It didn't make any difference. Having said that error code "'0x80004005' " suggests a permission error. Still couldn't figure it out. Appreciate any help ! Web config

<?xml version="1.0" encoding="utf-8"?>
  <location path="." inheritInChildApplications="false">
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      <aspNetCore processPath=".\MyApi.exe" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" hostingModel="InProcess" />
</configuration>`enter code here`
<!--ProjectGuid: 4d7644bb-9348-46f9-8397-95f01e03d599-->
asked on Stack Overflow Jan 10, 2020 by Taru • edited Jan 16, 2020 by Taru

1 Answer


Make sure you publish the site properly in iis. Your site root folder has enough permission to access it by iis. assign the iis_iusrs and iusr permission to the site folder. your application pool identity is set application pool identity or local system. anonymous authentication is enabled. and you installed the iis asp.net feature. make sure your site binding is correct and the application pool is using correct .net version and running under integrated application pool.

The reason behind the error message

The HTTP Error 502.5 - Bad Gateway and HTTP Error 502.5 - Process Failure error messages occur in ASP.NET Core when IIS fails to execute the dotnet process.

  • .NET Core Runtime is not installed
  • web.config file has not been transformed

To resolve this issue you could refer one the below-suggested way:

  1. Install the .NET Core Runtime

The most common reason for this to occur is when you haven't installed the .NET Core runtime on the server.

You can download the latest .NET Core runtime from Microsoft's .NET download page.

After installing Bundle stop iis and start again.

Publish a Self-Contained Deployment

If you don't want to install the .NET Core Runtime. An alternative for .NET Core web applications is to publish them in the Self-Contained deployment mode, which includes the required .NET Runtime files alongside your application.

enter image description here

If you go with this option, you'll also need to choose a target runtime: win-x86, win-x64, osx-x64, or linux-x64. Because self-contained deployments are not portable.

  1. Transform your web.config file

Another reason for this error to occur is when you deploy an untransformed web.config file.

This is likely to be your issue if you had a previously working web application and merely deployed a new version of it.

In ASP.NET Core applications, the web.config file contains a handler that directs requests to the AspNetCoreModule and an aspNetCore element that defines and configures the ASP.NET Core process to execute your web application.

Here is a minimal web.config file for an ASP.NET Core application:

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

The issue is The untransformed web.config contains the variables %LAUNCHER_PATH% and %LAUNCHER_ARGS% rather than the correct paths. When IIS tries to run ASP.NET Core, it uses %LAUNCHER_PATH% and %LAUNCHER_ARGS% rather than the correct path and arguments. To fix the HTTP Error 502.5 in ASP.NET Core, you need to transform the web.config and replace the untransformed web.config file on the IIS web server.

steps to transform web.config file:

This transformation takes place when you choose to publish your web application. The transformed web.config ends up in the published output folder. Therefore, you simply need to publish your web application and copy the resulting web.config file onto the server.

In a transformed web.config file, the aspNetCore element will look something like this:

<aspNetCore processPath="dotnet" arguments=".\MyApplication.dll" stdoutLogEnabled="true" 
stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" />

%LAUNCHER_PATH% has been replaced by dotnet and %LAUNCHER_ARGS% has been replaced by the path to the main web application dll .\MyApplication.dll.


Publish an ASP.NET Core app to IIS

answered on Stack Overflow Jan 13, 2020 by Jalpa Panchal

User contributions licensed under CC BY-SA 3.0