IIS deployment returns 502.5 Process Failure – Complete Fix | FreeLearning365.com

IIS deployment returns 502.5 Process Failure – Complete Fix | FreeLearning365.com
FreeLearning365.com 🖥️ IIS
🚨 Process Failure

IIS deployment returns 502.5 Process Failure
Complete Fix Guide

“HTTP Error 502.5 – Process Failure” — One of the most common errors when deploying ASP.NET Core applications to IIS. This guide provides a step-by-step troubleshooting approach to identify and fix the root cause, covering hosting bundle installation, permissions, logging, and configuration.

🔍 1. Introduction

You've built your ASP.NET Core application, published it, and deployed it to IIS. You navigate to the site, and instead of seeing your app, you get the dreaded HTTP Error 502.5 – Process Failure. This error indicates that the ASP.NET Core Module (ANCM) was unable to start the backend process (dotnet.exe) that hosts your application.

This error is frustrating because it provides very little detail. However, the fix is almost always a matter of checking a few common configuration points. This guide walks you through the systematic diagnosis and resolution of the 502.5 error, ensuring your app runs smoothly on IIS.

💡 Key insight: The 502.5 error is usually caused by missing runtime dependencies, incorrect application pool settings, or file permission issues. Most fixes are quick and don't require code changes.

2. Common Causes

  • .NET Core Hosting Bundle not installed – The server lacks the required runtime and ANCM.
  • Application pool misconfiguration – Wrong .NET CLR version or enable 32-bit applications setting.
  • Incorrect web.config – Missing aspNetCore element or wrong stdoutLog path.
  • File permissions – The application pool identity doesn't have read/write access to the app folder.
  • Missing environment variables – e.g., ASPNETCORE_ENVIRONMENT not set correctly.
  • Port conflict – If the app uses a specific port that is already taken.
  • Dependency issues – Missing native dependencies (e.g., Visual C++ Redistributable).
  • Logging folder permissions – If stdout logging is enabled, the folder must be writable.

📦 3. Install .NET Core Hosting Bundle

The ASP.NET Core Hosting Bundle includes the .NET Core runtime, the ASP.NET Core runtime, and the ASP.NET Core Module (ANCM) for IIS. If it's not installed, IIS cannot host ASP.NET Core applications.

✅ Download and Install

  • Go to the .NET Core Downloads page.
  • Find the version of .NET Core your app targets.
  • Download the Hosting Bundle (usually named dotnet-hosting-{version}-win.exe).
  • Run the installer on the IIS server.
  • Restart IIS (or the server) after installation.
✅ Verify: Check the installation by navigating to C:\Program Files\dotnet\ and ensuring dotnet.exe and the shared runtimes are present.

⚙️ 4. Application Pool Configuration

The IIS application pool must be configured correctly to run ASP.NET Core applications.

📌 Key Settings

  • .NET CLR version: Set to "No Managed Code" because ASP.NET Core runs in its own process.
  • Enable 32-bit Applications: If your app is 32-bit, set to True; otherwise, False.
  • Identity: Use ApplicationPoolIdentity (or a custom account) with proper permissions.
  • Start Mode: AlwaysRunning (recommended for better startup performance).
  • Idle Time-out: Set to 0 to prevent the app pool from shutting down.
# Via IIS Manager: 1. Open IIS Manager. 2. Select Application Pools → Your App Pool → Advanced Settings. 3. Set .NET CLR Version = "No Managed Code". 4. Set Enable 32-bit Applications = False (unless your app is 32-bit). 5. Set Start Mode = AlwaysRunning. 6. Set Idle Time-out (minutes) = 0.

📄 5. web.config Settings

The web.config file tells IIS how to handle the request. For ASP.NET Core, it must contain the <aspNetCore> element.

✅ Correct web.config for Out-of-Process

<?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="dotnet" arguments=".\YourApp.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" hostingModel="outofprocess" /> </system.webServer> </location> </configuration>

Note: The processPath should point to dotnet (or the full path). The arguments should point to your application's DLL. The hostingModel can be outofprocess or inprocess.

🔧 Common web.config Mistakes

  • Missing processPath or arguments.
  • Incorrect stdoutLogFile path – ensure the folder exists and is writable.
  • Using AspNetCoreModule instead of AspNetCoreModuleV2 (for .NET Core 2.2+).
  • Duplicate <handlers> entries.

🔐 6. File & Folder Permissions

The application pool identity must have read and execute permissions on the application folder, and write permissions on any folders used for logging or temporary files.

📌 Setting Permissions

  • Right-click your application folder → Properties → Security → Edit.
  • Add the application pool identity (e.g., IIS AppPool\YourAppPoolName).
  • Grant Read & Execute, List folder contents, and Read permissions.
  • If you have a logs folder for stdout logs, grant Write permission as well.
⚠️ Important: If you're using a custom service account, ensure that account has the same permissions.

📋 7. Enable Logging

Stdout logging is the most powerful tool for diagnosing the 502.5 error. It captures the output of the dotnet process, including any exceptions that occur during startup.

✅ Enable stdout Logging

In your web.config, set stdoutLogEnabled="true" and specify a log file path.

<aspNetCore ... stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" />

Then, create a logs folder in your application directory and ensure the app pool identity has write access to it.

📌 Reading the Logs

When the error occurs, check the logs folder for stdout_*.log files. These files contain the standard output of your application. Look for exceptions like FileNotFoundException, TypeLoadException, or MissingMethodException.

✅ Pro tip: Once the error is fixed, remember to turn off stdout logging in production to avoid unnecessary file writes.

🖥️ 8. Check Event Viewer

Windows Event Viewer logs detailed errors from the ASP.NET Core Module. This is a great source of additional information when stdout logs are not enough.

  • Open Event Viewer (Start → Run → eventvwr.msc).
  • Navigate to Windows Logs → Application.
  • Look for events with source ASP.NET Core Module or ANCM.
  • These events often include the exact error message and stack trace.

Common event IDs: 1000 (process start failure), 1001 (application error).

🔄 9. In-Process vs Out-of-Process

ASP.NET Core can run in two hosting models in IIS: In-Process and Out-of-Process. The error can occur in both modes, but the diagnosis may differ.

  • In-Process: The app runs inside the IIS worker process (w3wp.exe). Requires .NET Core 3.0+ and hosting bundle 3.0+.
  • Out-of-Process: The app runs in a separate dotnet.exe process. This was the default for .NET Core 2.2 and earlier.

To switch to in-process, set hostingModel="inprocess" in the aspNetCore element. In-process offers better performance but may have different permission requirements (e.g., the app pool identity needs access to the app folder).

If you get 502.5 in in-process mode, check that the app pool's .NET CLR version is "No Managed Code" and that the hosting bundle version matches your app's target framework.

❓ Frequently Asked Questions

🏆 11. Best Practices

  • Always install the .NET Core Hosting Bundle on the IIS server before deploying.
  • Use the same .NET Core version that your application targets.
  • Set the application pool to "No Managed Code" – this prevents IIS from loading the .NET Framework runtime.
  • Enable stdout logging only for debugging – turn it off in production to avoid performance issues.
  • Grant the application pool identity the necessary permissions – minimum: read/execute on the app folder, write on logs folder.
  • Use the dotnet publish command to produce a self-contained deployment if the server doesn't have the runtime installed.
  • Test the application from the command line on the server to verify it starts without IIS.
  • Monitor event logs for ANCM errors to proactively detect issues.
  • Keep the hosting bundle updated to the latest patch version.
✅ Final thought: The IIS 502.5 Process Failure error is usually a configuration or environment issue. With the systematic approach in this guide, you can quickly identify the root cause and get your ASP.NET Core application up and running on IIS.

Post a Comment

0 Comments