IIS Restart & Troubleshooting Guide
Prerequisites
Before running any commands, ensure you have:
- Access to the Windows Server running IIS
- Administrator privileges on that server
- IIS role installed and running
📝 Placeholder Standard
Throughout this guide:
- <"PLACEHOLDER"> = Replace with your value, keep the quotes
- <PLACEHOLDER> = Replace with your value, no quotes needed
- Examples:
<"DefaultAppPool">
becomes "DefaultAppPool"
- Property names like Name, State, PhysicalPath = Copy exactly as shown
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).
Open PowerShell as Administrator, then run:
Restart-Service W3SVC -Force
This restarts the World Wide Web Publishing Service and all dependent services.
- Press
Win + R
, type services.msc
- Find "World Wide Web Publishing Service"
- 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.
First, check which application pools exist:
Get-IISAppPool | Select-Object Name, State
Then restart the specific pool:
Restart-WebAppPool <"APP_POOL_NAME">
- Open IIS Manager (
Win + R
→ inetmgr
)
- Click "Application Pools" in the left panel
- Find your application pool
- 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.
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
- Open IIS Manager
- Click "Application Pools"
- Look for pools with "Stopped" status
- Right-click stopped pool → Start
- 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.
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">"
- IIS Manager → Select your website
- Double-click "Error Pages"
- Edit the 500 error → "Detailed errors" (temporarily for debugging)
- Check Event Viewer → Windows Logs → Application for ASP.NET errors
- 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.
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
- IIS Manager → Application Pools → Your App Pool → Advanced Settings
- Check Process Model → Identity (should be ApplicationPoolIdentity)
- Right-click website folder → Properties → Security
- Ensure IIS_IUSRS has Read & Execute permissions
- 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.
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
- Open Command Prompt as Admin
- Run:
netstat -ano | findstr :80
- Note the Process ID (last column)
- Task Manager → Details → find that PID
- 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.
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">
- Open Task Manager
- Go to Details tab
- Look for w3wp.exe processes using high CPU/Memory
- Note the Process ID (PID)
- In IIS Manager → Worker Processes → match PID to Application Pool
- Restart the identified application pool
Common Gotchas & FAQs
🎯 Application Pool Identity Gotchas
- Problem: App works locally but fails on server
- Cause: Application Pool Identity can't access databases/files
- Solution: Grant specific permissions or use NetworkService identity
- Common mistake: Using LocalSystem (too many privileges - security risk)
🔄 Restart vs Recycle - What's the Difference?
- Restart Website: Stops and starts the website - drops all connections
- Recycle App Pool: Overlapped recycling - no connection drops, graceful transition
- IIS Reset: Nuclear option - restarts entire IIS, affects ALL websites
- When to use each: 99% of time use App Pool recycling
❓ Frequently Asked Questions
- Q: Why does my app pool keep stopping?
A: Check Event Viewer for crash details, often memory leaks or unhandled exceptions
- Q: Can I run multiple versions of .NET on the same IIS?
A: Yes, use different application pools with different .NET versions
- Q: How often should I restart IIS?
A: Never on schedule - only when needed. Use app pool recycling for maintenance
- Q: Why is my website slow after deployment?
A: Cold start - first request compiles the application. Use app warm-up features
🚨 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