Troubleshooting HTTP 500 Startup Errors (ASP.NET Core)
If your ASP.NET Core application returns a generic "This page isn’t working (HTTP ERROR 500)" message immediately upon visiting it, the application is likely crashing during its startup sequence.
Common causes include:
- Database connection failures (e.g., incorrect connection string in
appsettings.json).
- Missing dependencies or unhandled exceptions in
Program.cs or Startup.cs.
- Failures during Entity Framework migrations.
- Missing configuration values (e.g., Social Login secrets).
Since the app crashes before it can load, it cannot display a friendly error page. Use the methods below to find the actual error message.
Method 1: Automated Startup Diagnostics (Recommended)
We provide a built-in tool that forces your application to restart and immediately captures any errors logged to the Windows Event Log during the crash.
- Navigate to the Event Viewer
- Log in to the control panel.
- Navigate to Websites and click on your website name.
- Select the Event viewer tab.
- Run the Test
- Click the RUN STARTUP DIAGNOSTICS link (located near the top right).
- A dialog will appear explaining the process (Recycling the app pool, calling the default URL, and retrieving logs).
- Click RUN THE TEST.
- View Results
- A new browser tab will open.
- If your application crashed, this page will display the specific stack trace or exception message from the Windows Event Log.
- If the page says "The application returned OK code," your application successfully started, and the issue may be related to internal routing or permissions rather than a startup crash.
Method 2: Enable Stdout Logging (Manual)
If the diagnostics tool does not reveal the issue, you can enable internal ASP.NET Core logging to capture raw output to a file.
- Edit Web.Config
- Go to the File manager tab for your website.
- Edit the
web.config file.
- Find the
<aspNetCore> element.
- Change
stdoutLogEnabled="false" to stdoutLogEnabled="true".
- Ensure the path is set correctly, e.g.,
stdoutLogFile=".\logs\stdout".
- Create the Logs Folder
- Crucial: You must ensure the
logs folder exists in your root directory. If it is missing, create it using the File manager or FTP.
- Reproduce the Error
- Visit your website again to trigger the error.
- Check the
/logs/ folder. You should see a new text file containing the detailed startup error.