Blog Post

IIS Support Blog
2 MIN READ

How to fix HTTP Error 500.37 - ASP.NET Core app failed to start within the startup time limit error

HridayDutta's avatar
HridayDutta
Icon for Microsoft rankMicrosoft
Oct 11, 2024

Introduction

ASP.NET Core applications hosted in IIS are designed to provide robust performance. However, sometimes issues arise that prevent apps from starting properly within the expected time. One common problem is the HTTP Error 500.37, which indicates that the application failed to start within the startup time limit.  This article will walk you through what causes this error and how to resolve it.

 

Problem

HTTP Error 500.37 occurs when an ASP.NET Core application hosted in IIS does not start within the allocated startup time. The default time limit is 120 seconds. This may happen due to various reasons such limited resource (CPU and memory), long initialization tasks, or inadequate startup time configurations in IIS. The error message usually looks like this -

This issue can be particularly problematic for larger or resource-intensive applications, where a longer startup time might be required to complete initialization tasks.

 

Solution

The good news is that this issue is easily fixable by increasing the startup time limit for the application in the web.config file. Here's a step-by-step guide to applying the fix:

 

Locate your application's web.config file, which should be in the root directory of your ASP.NET Core application. And update the startupTimeLimit  to a higher value then default 120 seconds in <aspNetCore> section.

 

 

 

<aspNetCore processPath="dotnet" arguments=".\YourApp.dll" stdoutLogEnabled="false" startupTimeLimit="360" />

 

 

 

In this example, the startupTimeLimit is set to 360 seconds (6 minutes). You can adjust this value based on the needs of your application. This configuration gives your application a longer window to initialize properly, preventing the 500.37 error from occurring.

 

Although, this fix will resolve the issue and allow the application to run smoothly, it's important to review the Startup.cs or Program.cs files to identify if any modules or dependencies are taking longer than expected to initialize. You can also grab a worker process dump or a profiler trace to find out where the time is being spent. 

 

Conclusion

HTTP Error 500.37 indicate startup failure of your ASP.NET Core application in IIS that requires more time to initialize. By adjusting the startupTimeLimit in the web.config file, you can give your application the necessary time to start and avoid startup errors. This simple yet effective solution ensures your application runs smoothly, even under complex startup conditions.

 

 

Updated Oct 14, 2024
Version 4.0
  • Hello RebeccaJS in addition to PradeepSharma's suggestion you can benchmark and measure execution time of individual services. Use stopwatch to monitor how long each operation takes.

    var stopwatch = Stopwatch.StartNew();
    
    // Initialize middleware here
    
    stopwatch.Stop();
    
    logger.LogInformation($"ConfigureServices took {stopwatch.ElapsedMilliseconds} ms");

     

  • Hey RebeccaJS 

    Review the Startup.cs or Program.cs files to identify if any modules or dependencies are taking longer than expected to initialize. Also, can also grab a worker process dump or a profiler trace to find out where the time is being spent.
    The maximum timeout for this can be set as 3600 (which is 1 hour). You may please refer to the documentation here.

     

    https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/web-config?view=aspnetcore-8.0 

  • RebeccaJS's avatar
    RebeccaJS
    Copper Contributor

    What is the maximum time limit? Mine is currently working at 240, is that normal?