IIS Restart & Troubleshooting Guide

Prerequisites

Before running any commands, ensure you have:

📝 Placeholder Standard

Throughout this guide:

Basic IIS Restart Operations

Full IIS Reset (Nuclear Option)

When to use: When IIS core services are corrupted or after major configuration changes.

Impact: ALL websites on the server will go down briefly (30-60 seconds).

💻 PowerShell Method (Recommended)

Open PowerShell as Administrator, then run:

Restart-Service W3SVC -Force

This restarts the World Wide Web Publishing Service and all dependent services.

🖱️ GUI Method
  1. Press Win + R, type services.msc
  2. Find "World Wide Web Publishing Service"
  3. Right-click → Restart

Restart Single Application Pool

When to use: When one specific website/application is having issues.

Impact: Only affects the specific application pool - other sites remain online.

💻 PowerShell Method

First, check which application pools exist:

Get-IISAppPool | Select-Object Name, State

Then restart the specific pool:

Restart-WebAppPool <"APP_POOL_NAME">
🖱️ GUI Method
  1. Open IIS Manager (Win + Rinetmgr)
  2. Click "Application Pools" in the left panel
  3. Find your application pool
  4. Right-click → Recycle

Common Issues & Solutions

❌ HTTP Error 503 - Service Unavailable

Most likely cause: Application pool has stopped or crashed

Troubleshooting approach: Check the application pool status first, then start it if stopped.

💻 PowerShell Diagnosis & Fix

Check all application pool states:

Get-IISAppPool | Where-Object {$_.State -eq 'Stopped'}

If you find stopped pools, start them:

Start-WebAppPool <"STOPPED_POOL_NAME">

Check for recent crashes in event logs:

Get-EventLog -LogName System -Source "WAS" -Newest 5
🖱️ GUI Diagnosis & Fix
  1. Open IIS Manager
  2. Click "Application Pools"
  3. Look for pools with "Stopped" status
  4. Right-click stopped pool → Start
  5. If it immediately stops again, check Event Viewer for error details
❌ HTTP Error 500 - Internal Server Error

Most likely causes: Application code errors, missing dependencies, configuration issues

Investigation approach: Check application event logs and enable detailed error messages to see the actual error.

💻 PowerShell Diagnosis

Check recent application errors:

Get-EventLog -LogName Application -EntryType Error -Newest 10 | Where-Object {$_.Source -like "*ASP.NET*"}

Enable detailed errors temporarily (NEVER on production):

Set-WebConfigurationProperty -Filter "system.web/customErrors" -Name mode -Value "Off" -PSPath "IIS:\Sites\<"SITE_NAME">"

After fixing, re-enable custom errors:

Set-WebConfigurationProperty -Filter "system.web/customErrors" -Name mode -Value "RemoteOnly" -PSPath "IIS:\Sites\<"SITE_NAME">"
🖱️ GUI Method
  1. IIS Manager → Select your website
  2. Double-click "Error Pages"
  3. Edit the 500 error → "Detailed errors" (temporarily for debugging)
  4. Check Event Viewer → Windows Logs → Application for ASP.NET errors
  5. After fixing, change back to "Custom error pages"
❌ HTTP Error 401 - Unauthorized

Most likely causes: Authentication configuration, file permissions, application pool identity issues

Common gotcha: Application pool identity doesn't have read permissions on the website files.

💻 PowerShell Diagnosis

Check application pool identity:

Get-IISAppPool <"APP_POOL_NAME"> | Select-Object Name, ProcessModel

Check file permissions:

Get-Acl <"C:\PATH\TO\WEBSITE"> | Select-Object -ExpandProperty Access

Grant IIS_IUSRS read permissions:

icacls <"C:\PATH\TO\WEBSITE"> /grant "IIS_IUSRS:(OI)(CI)R" /T
🖱️ GUI Method
  1. IIS Manager → Application Pools → Your App Pool → Advanced Settings
  2. Check Process Model → Identity (should be ApplicationPoolIdentity)
  3. Right-click website folder → Properties → Security
  4. Ensure IIS_IUSRS has Read & Execute permissions
  5. IIS Manager → Your Site → Authentication → check enabled methods
❌ Port Already in Use

Error message: "The process cannot access the file because it is being used by another process"

Common scenario: Trying to start a website on port 80 or 443 when another service is using it.

💻 PowerShell Diagnosis

Find what's using the port:

Get-NetTCPConnection -LocalPort <PORT_NUMBER> | Select-Object LocalAddress, LocalPort, State, OwningProcess

Get process details:

Get-Process -Id <PROCESS_ID>

Check HTTP.sys URL reservations:

netsh http show urlacl
🖱️ GUI Method
  1. Open Command Prompt as Admin
  2. Run: netstat -ano | findstr :80
  3. Note the Process ID (last column)
  4. Task Manager → Details → find that PID
  5. Identify the conflicting service

Performance Issues

❌ Worker Process Consuming High CPU/Memory

Symptoms: Server performance degradation, applications running slowly

Investigation approach: Identify which worker process is problematic, then restart its application pool.

💻 PowerShell Investigation

Find worker processes and their resource usage:

Get-Process w3wp* | Select-Object Id, CPU, WorkingSet, @{Name="AppPool";Expression={(Get-WmiObject Win32_Process -Filter "ProcessId=$($_.Id)").CommandLine}}

Once you identify the problematic app pool, restart it:

Restart-WebAppPool <"PROBLEMATIC_POOL_NAME">
🖱️ GUI Investigation
  1. Open Task Manager
  2. Go to Details tab
  3. Look for w3wp.exe processes using high CPU/Memory
  4. Note the Process ID (PID)
  5. In IIS Manager → Worker Processes → match PID to Application Pool
  6. Restart the identified application pool

Common Gotchas & FAQs

🎯 Application Pool Identity Gotchas

🔄 Restart vs Recycle - What's the Difference?

❓ Frequently Asked Questions

🚨 Production Safety Rules:
• Never enable detailed error messages on production
• Always test configuration changes on staging first
• Use App Pool recycling instead of IIS reset when possible
• Monitor memory usage after deployments to catch leaks early