Application keeps restarting or loses sessions

The usual reasons an application is restarted and how to find the cause.

Users are logged out unexpectedly, in-memory data disappears, SignalR connections drop or the first request is slow from time to time. All of these are signs that the application was restarted.

A restart does not have to mean a crash. Many ordinary actions restart an application.

Normal reasons for a restart

  • Publishing a new version with Web Deploy.
  • Uploading or changing application files over FTP.
  • A change to web.config or appsettings.json.
  • Changing a setting of the website in the Control Panel (for example on the Scripting page).
  • Restarting the application in the Control Panel.
  • No visitors for a while — an idle application is stopped and started again by the next request. See Keep your application always running.
  • Planned maintenance of the server, such as Windows updates.

Restarts caused by the memory limit

If the restarts are frequent, the application is probably reaching its memory limit. Open Logs for the website and look for:

A worker process serving application pool 'siteXXXX' has requested a recycle because it reached its private bytes memory limit.

The fix is to lower the memory usage of the application or to add more memory — see Increase the memory (RAM) of a website.

Restarts caused by a crash

An unhandled exception in a background thread or an out-of-control recursion ends the whole process. The Logs page shows an Application Error entry with the exception. ASP.NET Core debug logging gives you more detail.

Make your application survive restarts

Because restarts are a normal part of hosting, an application should not depend on data kept only in memory.

  • Sessions and caches: keep important state in the database or in a distributed cache instead of in-process memory.
  • Login cookies in ASP.NET Core: persist the Data Protection keys (for example to a folder of the website or to the database). Otherwise new keys are generated on every start and all users are signed out.
  • Background jobs: store their state so that an interrupted job can continue after a restart.

Asking support about a restart

Tell us the exact date and time of the restart and confirm that none of the actions listed above happened at that moment. Without it we usually cannot tell one restart from another in the logs.

Still stuck? Our support team is happy to help.
Ask the community Open a support ticket