39

My website was down several times per day and when I check the application pool (IIS 7.5), I saw it was stopped and I must restart it manually. How can I setup application pool so that it automatically restarts after an error?

1
  • 5
    The bigger question is why is your application pool stopping. Check your event logs and try to figure out what is causing them to stop.
    – Nick Bork
    Feb 14, 2012 at 17:26

3 Answers 3

65

You will need to change the startMode for the application pool your website is running on from onDemand to AlwaysRunning. By default IIS sets all application pools to onDemand.

  1. In IIS Manager, click computer name in the Connection pane.
  2. Switch to Features View if the view is not active.
  3. Double-click Configuration Editor in the Management section of the Features View.
  4. Click the down-arrow for the Section field, expand system.applicationhost, and then click application pools.
  5. Click (Collection) and then click ellipses (…) next to the field that shows the count.
  6. In the Collection Editor, select the application pool for which you want to configure the startMode attribute.
  7. In the Properties window at the bottom, set the value of startMode attribute to AlwaysRunning.

Source: http://msdn.microsoft.com/en-us/library/ee677285%28v=azure.10%29.aspx

In IIS 8 and above, the start mode setting is now directly available from the Application Pool's Advanced Settings.

5
  • I can't believe I never knew about that, and I'm surprised it's not the default. I can't think of a reason you wouldn't want it set, especially for any public-facing web app. Dec 30, 2013 at 20:47
  • The defaults in IIS are all pretty much optimized for .NET and development sites. When you are running PHP for example you have to change a lot of settings especially when it comes to recycling.
    – Chaoix
    May 6, 2014 at 14:52
  • 7
    In IIS 8 and above, the start mode setting is now directly available from the Application Pool's Advanced Settings.
    – Chaoix
    Jul 9, 2015 at 18:36
  • 1
    Do you need to restart the app pool for this to take affect, or will it work straight after applying the setting? Nov 14, 2017 at 1:47
  • 1
    Chaoix, you should post your suggestion as an answer because that is the correct way to do it.
    – Vincent
    Oct 30, 2018 at 21:52
3

In IIS 8 and above, the startMode setting is now directly available from the Application Pool's Advanced Settings.

Changing the startMode to AlwaysRunning will automatically restart the Application Pool if it fails.

https://learn.microsoft.com/en-us/iis/configuration/system.applicationhost/applicationpools/add/#new-in-iis-75-and-later

1

Problem with "By default IIS sets all application pools to onDemand" is when you have to update the bits. Then the site will restart and lock the deployment. Better to set the Rapid-fail protection under advanced settings under app pool. Set Failure interval (min) to 1, and Max fail to 5.

2
  • "Update the bits"?
    – Vincent
    Oct 30, 2018 at 21:51
  • 2
    @Vincent That probably means "deploying new content and binaries"
    – NReilingh
    Mar 28, 2019 at 15:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.