Fix ASP.NET Core IIS Errors 500.30 and 500.31 on AWS EC2

Why does my ASP.NET Core app run locally but fail to start in IIS on EC2?
IIS error 500.30 usually means the in-process ASP.NET Core application could not start. Error 500.31 points to a failure to find native dependencies, commonly a missing shared framework. Start with the Application event log on the EC2 server, then follow the branch for the displayed substatus.

Identify what IIS is actually running
This example uses Windows Server, IIS, PowerShell, an x64 application pool called Shop, and a framework-dependent .NET 10 deployment. Use an authorized administrative session on the EC2 instance. In IIS Manager, record the site’s physical path, application pool and current bindings. Look at the deployed web.config and Shop.runtimeconfig.json. Check your timestamps against the last deployment and capture the event generated when you reproduce the error.
Set-Location C:\inetpub\Shop
Get-Content .\Shop.runtimeconfig.json
& "$env:ProgramFiles\dotnet\dotnet.exe" --list-runtimes
Get-WinEvent -FilterHashtable @{
LogName = 'Application'; StartTime = (Get-Date).AddMinutes(-20)
} | Where-Object ProviderName -Match 'AspNetCore|\.NET Runtime' |
Select-Object TimeCreated, ProviderName, Id, Message
500.31 — check the framework, architecture and IIS module
Compare the application’s runtime configuration with Microsoft.NETCore.App and Microsoft.AspNetCore.App in the runtime list. Check the x86 installation under Program Files (x86) if the pool enables 32-bit applications. Match the app deployment and worker-process architecture. Install or repair the supported Hosting Bundle for the required major version. If IIS was installed after the bundle, repair it after IIS is present. Confirm the ASP.NET Core Module is available in IIS and plan the required service restart in a maintenance window, because restarting WAS affects other sites.
500.30 — reproduce and isolate the startup exception
From the deployment directory run the command configured in web.config, such as dotnet Shop.dll. Capture its first exception and stop the diagnostic process when finished. A successful administrator launch still leaves differences in IIS identity, environment and bindings. Check configuration present only on the developer machine, missing environment variables, certificate private-key permissions, and database connectivity. Check whether the pool identity can read the published files and write only to designated directories. Grant permissions to IIS AppPool\Shop on the needed directory, with the minimum access required.
Capture stdout temporarily and verify recovery
Back up web.config. Existing aspNetCore element attributes can temporarily set stdoutLogEnabled="true" and stdoutLogFile=".\logs\stdout". Create the logs directory and give the specific pool identity write access there. Reproduce one request, read the newest log locally, disable stdout logging and handle the diagnostic file under your retention policy. Recycle the affected pool and verify a cold-start request and a real application request through HTTPS. If a deployment caused the incident, restore the last known-good artifact and matching configuration, then check for new startup events.
Frequently asked questions
Can changing the security group fix a 500.31 response?
A returned IIS response demonstrates the request already reached IIS. Inspect the server runtime and module.
Do I need the SDK on the EC2 instance?
A framework-dependent publish requires matching runtimes and the IIS hosting module. Build on a development or CI machine.
Does self-contained deployment still use ANCM?
Yes, IIS still uses the ASP.NET Core Module for this hosting integration.
Why does the app run from PowerShell yet fail in IIS?
The IIS worker can use a different identity, architecture, environment and working context.
Can stdout remain enabled?
Use it for a short diagnostic window because logs can grow and may contain sensitive startup details.
Comments
Post a Comment