It’s a frustrating scenario for any system administrator: your critical ERP software, hosted on a Hetzner Windows VM, works perfectly all day, but every morning, users report they can’t log in. The application is unresponsive until you manually restart IIS or reboot the entire virtual machine. This pattern points to an overnight process that is causing the application to hang.

This guide will walk you through diagnosing this common issue—often tied to host-level maintenance or backups—and provide a step-by-step, automated solution to ensure your ERP is ready for business every morning.

Diagnosing the Problem: The Midnight Freeze

The symptoms are consistent:

  1. The ERP application and its database work flawlessly during business hours.

  2. Sometime after midnight, the application becomes unresponsive. Login attempts fail.

  3. A manual iisreset command or a full VM reboot temporarily solves the problem.

The timing is the biggest clue. Cloud providers like Hetzner often run automated maintenance, network updates, or VM backups (often using Proxmox) during off-peak hours, typically starting around midnight. These operations can briefly “stun” or freeze a VM’s disk I/O for a snapshot. If the IIS worker process (w3wp.exe) or the database connection is in a sensitive state, this momentary pause can cause it to enter a hung state from which it cannot recover on its own.

Restarting IIS forcibly terminates the hung process and starts a fresh one, which is why it resolves the login issue. Our goal is to automate this recovery process so it happens seamlessly every night.

Copyright @EngineerHow.com

The Solution: Automated IIS Application Pool Recycling

Instead of restarting the entire IIS server (iisreset), which can affect other sites, the most precise and efficient solution is to recycle only the specific Application Pool used by your ERP software. This gracefully restarts the worker process for that application alone. We will automate this using a Windows Scheduled Task.

Step 1: Identify Your ERP’s Application Pool Name

First, you need to know the exact name of the application pool your ERP site is using.

  1. Open Internet Information Services (IIS) Manager on your server.

  2. In the Connections pane on the left, expand your server name, then expand Sites.

  3. Click on your ERP website. In the Actions pane on the right, click Basic Settings….

  4. A dialog box will appear. The Application pool: field shows the name you need. Note it down exactly. For this example, we’ll use YourERPPool.

Step 2: Create a Scheduled Task to Automate the Recycle

This task will run a command to recycle the app pool every night, just after the likely maintenance window begins.

  1. Open Task Scheduler from the Start Menu (search for taskschd.msc).

  2. In the Actions pane on the right, click Create Task….

  3. General Tab:

    • Name: ERP Midnight App Pool Recycle

    • Description: Automatically recycles the ERP application pool to prevent overnight hangs.

    • Select Run whether user is logged on or not.

    • Check the box for Run with highest privileges.

  4. Triggers Tab:

    • Click New….

    • Set the trigger to Daily.

    • Set the Start time to a time shortly after the outage begins, for example, 12:05:00 AM. This gives the maintenance time to start and ensures your reset happens right after.

    • Ensure Enabled is checked and click OK.

  5. Actions Tab:

    • Click New….

    • Action: Start a program.

    • Program/script: C:\Windows\System32\inetsrv\appcmd.exe

    • Add arguments (optional): recycle apppool /apppool.name:"YourERPPool" (Remember to replace YourERPPool with the actual name from Step 1).

    • Click OK.

  6. Conditions & Settings Tabs:

    • Review these tabs. The default settings are usually fine.

    • Click OK to save the task. You will be prompted to enter the password for the user account running the task.

Your automated fix is now active. The task will run every morning at 12:05 AM, recycling the application pool and preventing the hung state, ensuring the ERP is available without manual intervention.

Alternative and Long-Term Solutions

While the automated recycle is an excellent immediate fix, for maximum uptime, consider these more advanced strategies.

Approach

Pros

Cons

Best For

IIS App Pool Recycling

Quick, easy, and highly effective for this issue.

Doesn’t fix the underlying host-level cause.

Immediate, reliable resolution with minimal effort.

Load Balancing / Failover

Provides true 24/7 uptime, even during maintenance.

Requires extra servers and configuration.

Mission-critical systems where zero downtime is required.

External Session Store

Prevents session loss if app pool recycles.

Requires application code/config changes.

Applications that must maintain user state across resets.

Modify Proxmox Backups

Avoids the VM freeze entirely if backups are the cause.

May require coordination with Hetzner support.

When you have control over the backup mode.

Migrate to Higher SLA

A permanent fix at the infrastructure level.

Higher cost for a dedicated server or premium plan.

When business requirements outgrow the current plan.

Conclusion

The “midnight freeze” is a common headache for applications hosted on shared infrastructure. By setting up a simple, automated task to recycle the specific IIS Application Pool, you can create a robust and self-healing system that withstands nightly maintenance cycles. This approach is the most direct and reliable solution, saving you from early morning support calls and ensuring business continuity. @EngineerHow.com

We recommend bookmarking this guide from EngineerHow.com for future reference. Our goal is to make complex technical topics simple and accessible for everyone.

🔗 Useful Links 📺 EngineerHow YouTube Channel (www.youtube.com/@EngineerHow)

📢 About EngineerHow.com EngineerHow.com is dedicated to providing expert IT and engineering tutorials, helping professionals and enthusiasts set up servers, networks, and self-hosted solutions. Our guides focus on step-by-step instructions to make complex topics easy to understand.

🚀 Explore More IT Guides: EngineerHow.com

💬 Join the Discussion! Have questions or insights? Drop a comment below and let’s discuss!

Copyright © 2025 EngineerHow.com. All Rights Reserved.