Comprehensive IIS Troubleshooting Guide

Table of Contents

1. [Log Locations](#log-locations)

2. [Common HTTP Error Codes](#common-http-error-codes)

3. [GUI Troubleshooting Methods](#gui-troubleshooting-methods)

4. [PowerShell Troubleshooting Methods](#powershell-troubleshooting-methods)

---

Log Locations

IIS Access Logs

- GUI: IIS Manager → Sites → [YOUR_SITE_NAME] → double-click "Logging" icon → Directory path shows location

- PowerShell: gwc "system.webserver/httpLogging" "IIS:\Sites\[SITE]"

Windows Event Logs

.NET/ASP.NET Logs

---

Common HTTP Error Codes

400 - Bad Request

Common Causes: URL too long, malformed headers, invalid characters in request

GUI Troubleshooting:

1. Open IIS Manager → Start Menu → type "IIS Manager" → Enter

2. Navigate to site → Expand server name → Expand "Sites" → Click [YOUR_SITE_NAME]

3. Check Request Filtering:

- Double-click "Request Filtering" icon in main panel

- Click "Edit Feature Settings" in right panel

- Check "Maximum URL length" and "Maximum query string" values

4. Check Request Limits:

- In Request Filtering → "Request Limits" tab

- Check "Maximum allowed content length"

PowerShell Debugging:


# Check request limits
gwc "system.webserver/security/requestFiltering/requestLimits" "IIS:\Sites\[SITE]"

# URL length limit
(gwc "system.webserver/security/requestFiltering/requestLimits" "IIS:\Sites\[SITE]").maxUrl

---

401 - Unauthorized

Common Causes: Wrong credentials, authentication not configured, app pool identity issues

GUI Troubleshooting:

1. Check Authentication Methods:

- IIS Manager → Sites → [YOUR_SITE_NAME] → Double-click "Authentication" icon

- Location: Main panel shows all auth methods (Anonymous, Windows, Forms, etc.)

- Right-click method → "Enable" or "Disable"

2. Check Application Pool Identity:

- IIS Manager → Click "Application Pools" in left panel

- Find [YOUR_APP_POOL_NAME] → Right-click → "Advanced Settings"

- Location: "Process Model" section → "Identity" field shows current identity

- Click "..." button to change identity

3. Check NTFS Permissions:

- Windows Explorer → Navigate to [YOUR_WEBSITE_FOLDER]

- Right-click folder → "Properties" → "Security" tab

- Verify "IIS_IUSRS" and your app pool identity have "Read & Execute" permissions

PowerShell Debugging:


# Check enabled auth
gwc "system.webserver/security/authentication/*" "IIS:\Sites\[SITE]" | ?{$_.enabled}

# App pool identity
(Get-IISAppPool [POOL]).ProcessModel.IdentityType
(Get-IISAppPool [POOL]).ProcessModel.UserName

# NTFS perms
(gacl [PATH]).Access | ?{$_.IdentityReference -like "*IIS_IUSRS*"}

---

403 - Forbidden

Common Causes: NTFS permissions, directory browsing disabled, IP restrictions, SSL required

GUI Troubleshooting:

1. Check Directory Browsing:

- IIS Manager → Sites → [YOUR_SITE_NAME] → Double-click "Directory Browsing"

- Location: "Actions" panel on right → Click "Enable" if needed

2. Check IP Restrictions:

- IIS Manager → Sites → [YOUR_SITE_NAME] → Double-click "IP Address and Domain Restrictions"

- Location: Main panel shows allowed/denied IPs

- "Actions" panel → "Add Allow Entry" or "Add Deny Entry"

3. Check SSL Requirements:

- IIS Manager → Sites → [YOUR_SITE_NAME] → Double-click "SSL Settings"

- Location: "Require SSL" checkbox and "Client certificates" options

4. Check Default Document:

- IIS Manager → Sites → [YOUR_SITE_NAME] → Double-click "Default Document"

- Location: Main panel shows list of default documents (index.html, default.aspx, etc.)

PowerShell Debugging:


# Directory browsing
(gwc "system.webserver/directoryBrowse" "IIS:\Sites\[SITE]").enabled

# IP restrictions
gwc "system.webserver/security/ipSecurity" "IIS:\Sites\[SITE]"

# SSL settings
gwc "system.webserver/security/access" "IIS:\Sites\[SITE]"

# Default docs
gwc "system.webserver/defaultDocument/files" "IIS:\Sites\[SITE]"

---

404 - Not Found

Common Causes: File doesn't exist, handler not configured, routing issues

GUI Troubleshooting:

1. Verify File Exists:

- Windows Explorer → [YOUR_WEBSITE_PHYSICAL_PATH]

- Check if requested file actually exists

2. Check Handler Mappings:

- IIS Manager → Sites → [YOUR_SITE_NAME] → Double-click "Handler Mappings"

- Location: Main panel shows all handlers (.aspx, .php, .html, etc.)

- Look for handler matching your file extension

3. Check MIME Types:

- IIS Manager → Sites → [YOUR_SITE_NAME] → Double-click "MIME Types"

- Location: Main panel shows file extensions and MIME types

- "Actions" panel → "Add" to add missing MIME type

PowerShell Debugging:


# File exists?
Test-Path "[PATH]\[FILE]"

# Handlers
gwc "system.webserver/handlers" "IIS:\Sites\[SITE]"

# MIME types
gwc "system.webserver/staticContent" "IIS:\Sites\[SITE]"

# URL rewrite (if installed)
gwc "system.webserver/rewrite/rules" "IIS:\Sites\[SITE]"

---

500 - Internal Server Error

Common Causes: Code errors, web.config syntax errors, missing dependencies

GUI Troubleshooting:

1. Enable Detailed Errors (TEMPORARILY):

- IIS Manager → Sites → [YOUR_SITE_NAME] → Double-click "Error Pages"

- Location: Find "500" in main panel → Right-click → "Edit"

- Change "Response action" to "Detailed errors" → OK

- IMPORTANT: Change back to "Custom error pages" after troubleshooting

2. Check Application Pool Status:

- IIS Manager → "Application Pools" in left panel

- Location: Find [YOUR_APP_POOL_NAME] → Check "State" column

- If "Stopped" → Right-click → "Start"

3. Check Event Logs:

- Start → "Event Viewer"

- Location: Windows Logs → Application

- Look for recent errors from "ASP.NET" or "IIS"

PowerShell Debugging:


# Enable detailed errors (temp)
swc "system.webserver/httpErrors/error[@statusCode='500']" @{responseMode="Detailed"} "IIS:\Sites\[SITE]"

# App pool status
Get-IISAppPool [POOL] | select Name,State

# Recent errors
gel Application -Source "*ASP.NET*" -Newest 5 | select TimeGenerated,Source,Message

# Config valid?
Test-Path "[PATH]\web.config"

---

502 - Bad Gateway

Common Causes: App pool crashed, CGI timeout, proxy issues

GUI Troubleshooting:

1. Check Application Pool:

- IIS Manager → "Application Pools"

- Location: Find [YOUR_APP_POOL_NAME] → Check "State" column

- If "Stopped" → Right-click → "Start"

2. Check App Pool Settings:

- Right-click [YOUR_APP_POOL_NAME] → "Advanced Settings"

- Key Settings to Check:

- "Process Model" → "Idle Time-out": Default 20 minutes

- "Recycling" → "Regular Time Interval": Default 1740 minutes

- "Rapid-Fail Protection" → "Enabled": Should be True

3. Check FastCGI Settings (for PHP/other CGI apps):

- IIS Manager → Server level → Double-click "FastCGI Settings"

- Location: Main panel shows configured FastCGI applications

- Double-click entry → Check "Activity Timeout" and "Request Timeout"

PowerShell Debugging:


# App pool status & restart
Get-IISAppPool [POOL]
Restart-WebAppPool [POOL]

# Rapid-fail events
gel System -Source "*WAS*" -Newest 10 | ?{$_.Message -like "*[POOL]*"}

# Worker processes
gwmi Win32_Process -Filter "Name='w3wp.exe'" | select ProcessId,CommandLine

# FastCGI settings
gwc "system.webserver/fastCgi/application" "IIS:\"

---

503 - Service Unavailable

Common Causes: App pool stopped, overloaded, rapid-fail protection triggered

GUI Troubleshooting:

1. Check Application Pool Status:

- IIS Manager → "Application Pools"

- Location: [YOUR_APP_POOL_NAME] "State" column

- If "Stopped" → Right-click → "Start"

2. Check Rapid-Fail Protection:

- Right-click [YOUR_APP_POOL_NAME] → "Advanced Settings"

- Location: "Rapid-Fail Protection" section

- "Enabled": True/False

- "Failure Count Threshold": Default 5

- "Failure Interval": Default 5 minutes

- If triggered → Right-click app pool → "Start"

3. Check Queue Length:

- In Advanced Settings → "General" section

- Location: "Queue Length": Default 1000

- If too low, increase value

PowerShell Debugging:


# Start app pool
Start-WebAppPool [POOL]

# Rapid-fail status
(Get-IISAppPool [POOL]).Failure

# Reset rapid-fail
Reset-WebAppPool [POOL]

# Queue size
gc "\HTTP Service Request Queues([POOL])\CurrentQueueSize" -ea 0

---

GUI Troubleshooting Methods

Quick Navigation Reference

Essential GUI Tools

#### Failed Request Tracing

1. Enable: IIS Manager → Sites → [YOUR_SITE_NAME] → "Actions" panel → "Failed Request Tracing"

2. Configure Rules: Click "Add" → Select content type → Set status codes → Set trace providers

3. View Logs: Navigate to C:\inetpub\logs\FailedReqLogFiles\W3SVC[SITE_ID]

#### Worker Processes Monitor

1. Access: IIS Manager → Server level → Double-click "Worker Processes"

2. View Requests: Double-click active w3wp.exe process

3. Location: Shows currently executing requests with URL, time elapsed, client IP

---

PowerShell Troubleshooting Methods

Import Modules


ipmo WebAdministration,IISAdministration

Quick Checks


# Services
gsv W3SVC,WAS

# Sites
Get-IISSite | select Name,ID,State,@{n="Path";e={$_.Applications[0].VirtualDirectories[0].PhysicalPath}}

# App pools
Get-IISAppPool | select Name,State,ProcessModel

# Bindings
Get-IISSiteBinding | select SiteName,Protocol,BindingInformation

# Which pool for site
(Get-IISSite [SITE]).Applications.ApplicationPoolName

Logs


# Latest IIS log (last 50 lines)
$log = gci "C:\inetpub\logs\LogFiles\W3SVC[ID]" -Filter "*.log" | sort LastWriteTime -Desc | select -First 1
gc $log.FullName | select -Last 50

# Errors only
gc "C:\inetpub\logs\LogFiles\W3SVC[ID]\*.log" | ?{$_ -like "*50[0-9]*"} | select -Last 20

# App errors
gel Application -EntryType Error -Newest 10 | ?{$_.Source -like "*IIS*" -or $_.Source -like "*ASP.NET*"}

Performance


# Worker process stats
gwmi Win32_Process -Filter "Name='w3wp.exe'" | select ProcessId,@{n="MemMB";e={[math]::Round($_.WS/1MB,2)}},CommandLine

# Key counters
$ctrs = "\Web Service(_Total)\Current Connections","\Web Service(_Total)\Requests/Sec","\Process(w3wp)\% Processor Time"
gc $ctrs -SampleInterval 2 -MaxSamples 3

Config


# Backup
Backup-WebConfiguration "Backup_$(Get-Date -f 'yyyyMMdd_HHmm')"

# List backups
gwc "system.applicationHost/configHistory" | select path,created