74

I deploy a .NET Core 5 app with settings: enter image description here

And the website shows an error:

HTTP Error 500.30 - ASP.NET Core app failed to start Common solutions to this issue:

  • The app failed to start
  • The app started but then stopped
  • The app started but threw an exception during startup

Troubleshooting steps:

  • Check the system event log for error messages
  • Enable logging the application process' stdout messages
  • Attach a debugger to the application process and inspect

For more information visit: https://go.microsoft.com/fwlink/?LinkID=2028265

What is causing this error?

zhulien
  • 5,145
  • 3
  • 22
  • 36
Paolo Constantin
  • 745
  • 1
  • 5
  • 4

30 Answers30

83

There may be a few reasons behind the error which you can only identify by debugging. You can try to debug this error using the steps below:

  1. Navigate to the root directory of the application using CMD
  2. Run the application using the command dotnet run (yourApplicationName).dll

If there are any errors, they should appear in the output.

Alternatively, you can check "Event Viewer" (search Event Viewer using Windows search) and navigate to

  • Windows Logs
    • Application

Update:

dotnet (yourApplicationName).dll

and check http://localhost:5000/ for error

biberman
  • 5,606
  • 4
  • 11
  • 35
uvylight
  • 849
  • 5
  • 3
73

enter image description here

Go there, and try to manually start your project... i.e.

dotnet ServerApp.dll

enter image description here

130nk3r5
  • 1,120
  • 10
  • 12
  • 10
    This helped me find he root cause of the issue. In my case my connection string was incorrect and app was unable to connect to database at the start of application. – Asad Feb 08 '22 at 16:51
  • Any chance you could share the command? – TomSelleck Feb 15 '22 at 21:04
  • So since I have a dotnet blazor wasm app, I simply ran “donet ServerApp.dll” – 130nk3r5 Feb 16 '22 at 05:59
  • Great advice. My case was lacking connection to Key Vault. – axelio Jul 07 '22 at 10:30
  • we had the same problem and indeed a connection string in appsettings.json was malformed, there was a backslash that was not escaped with another backslash in the. so double backslash solved the problem "\\" – somedotnetguy Mar 21 '23 at 16:33
  • you can navigate to the logfiles directory: type cd ../../logfiles (assuming you started in c:/home/site/wwwroot. then enter this command: "type eventlog.xml" - assuming this file is in the logfiles folder (which it should be if you are getting a 500.30. (fwiw my web api was looking for a specific folder that did not exist) – Bernard Jul 26 '23 at 19:25
20

open Windows Event Viewer, find the error message and click it, open the Detail tab, you will see the exception.

Harrison Wu
  • 354
  • 2
  • 4
  • Event Viewer helped a lot. I was able to see that "System.UnauthorizedAccessException: Access to the path 'C:\WINDOWS\system32\config\systemprofile' is denied." then I simply browsed to that folder in Explorer and gave myself access – Brent May 30 '23 at 15:38
11

I recently encountered this issue deploying my .net core 5 app to IIS. I am using environment variables for my various envrionments and the web.config that was deployed was missing the xml tags.

Changing this line:

<aspNetCore processPath="dotnet" arguments=".\<your>.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess"/>

to:

<aspNetCore processPath="dotnet" arguments=".\<your>.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess">
   <environmentVariables>
        <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Local" />
   </environmentVariables>
</aspNetCore>

This fixed my 500.30 issue.

I took guidance from @Mohammed https://stackoverflow.com/a/59390437/6155498

PaulGrant
  • 358
  • 3
  • 9
8

I had this error running the application on local IIS in windows 10, then I gave full control permission to IIS_IUSRS for App_Data and Logs folders so it worked.

enter image description here

Jalaleddin Hosseini
  • 2,142
  • 2
  • 25
  • 28
5

This is a very vague error message, there can be 100s of different reasons behind it. Check your server error logs.

In my case Redeploying the application targeting the 64-bit platform fixed the issue.

Manzur Alahi
  • 1,870
  • 23
  • 19
4

I got the error using Azure App Service

HTTP Error 500.30 - ASP.NET Core app failed to start

The documentation and App Service logs did not get me anywhere.

https://learn.microsoft.com/en-gb/aspnet/core/test/troubleshoot-azure-iis?view=aspnetcore-6.0#50030-in-process-startup-failure

I then logged on to the database and checked Firewalls and virtual networks and saw that Allow Azure services and resources to access this server was set to No. Switching Allow Azure services and resources to access this server to Yes solved the error.

enter image description here

A good place to check is also Azure App Service - Diagnose and solve problems. Another problem I had could be solved using Application Event Logs.

enter image description here

In this case it was the error:

System.InvalidOperationException: Couldn't find a valid certificate with subject 'CN=certificate' on the 'CurrentUser\My'

Turned out I had a expired certificate, renewed and everything worked.

Ogglas
  • 62,132
  • 37
  • 328
  • 418
4

When the top two answers didn't immediately resolve this error, I started down a deep road of depression wondering "what happened to the azure point, click, done experience I've enjoyed for over 10 years?". And began randomly clicking around the app service page, grasping without hope.

As a last chance (it's always the last chance, isn't it?) I clicked on the "Diagnose and solve problems" link. I had gone down this road before and thought it on only had alert-related stuff.

And then I saw the "Genie" link. "Omg I am so done with the failed promise of chat bots!" I scroamed (screamed and groaned) silently and clicked the link, eyes closed.

And got this...

enter image description here

I had initially wanted to self-host and had been using (minimal api template) "builer.WebHost.UseKestrel". Commented it out and good to go.

Rodney
  • 179
  • 7
3

Check whether the attribute value of hostingModel in the configuration file is OutOfProcess. If the value of the hostingModel property is InProcess, try to change it to OutOfProcess and start the project again.

Ding Peng
  • 3,702
  • 1
  • 5
  • 8
  • this is my .csjproj PropertyGroup net5.0 ManToc.Api.xml 1701;1702;1591 07acd440-eb4a-416e-b906-90c692d326b3 – Paolo Constantin Apr 24 '21 at 22:07
  • You can refer to this link to set the value of the hostingModel property: https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/out-of-process-hosting?view=aspnetcore-5.0 – Ding Peng Apr 26 '21 at 07:16
  • You may also have to delete the _web.config_ file in the app service and republish the site so that web.config actually changes. – CrispinH Dec 31 '21 at 13:35
3

Ran into this problem today (NET 5 app, win-x64 target runtime). I managed to fix it by disabling 32-bit applications support in the IIS Application Pool (see screenshot below):

IIS Application Pool configuration

As soon as I've switched from Enable 32-Bit Applications: true to false, the HTTP Error 500.30 disappeared.

For additional info, see this post on my blog.

Darkseal
  • 9,205
  • 8
  • 78
  • 111
3

I also encountered this bug. With the difference that the target framework of my program is .NET 6.

The mistake I made was not to put the app.Run() command in the Program.cs.

3

I solved this error, using this information,

this issue is mainly with the appsettings.json, the error is caused by the unwanted character in the appsettings.json. To find out exactly what the cause of the HTTP Error 500.30 is, start an application called EventViewer and navigate to System Events. You will be able to see an Event Log of IIS and the main cause of an Error.

sources : https://www.ernestech.com/articles/details/6899/http-error-500.30---aspnet-core-app-failed-to-start#:~:text=but%20then%20stopped-,Answer%3A%20To%20be%20able%20to%20troubleshoot%20this%20issue%20is%20mainly,and%20navigate%20to%20System%20Events.

turns out I had given a wrong path in appsettings.json with too many slashes ////.

3

I solved this issue by taking the following steps:

  1. Go to "Windows search"
  2. search "Event viewer" and open the application
  3. Search under the folder "Windows Logs" > "Application"
  4. Check the "Error" level warnings

This should identify your error, you should now take steps to take the appropriate actions. In my case, I had the error of "System.IO.DirectoryNotFoundException".

This error arose due to my application not having the rights to access an external sever.

I went back to my "Application Pool" settings, changed my "application pool Identity" to a user which did have access rights to the server, restarted my application and viola!

All works well.

This is my experience of this error. As said in an earlier post, this error has many remedies depending on the underlying issue

Dwalte
  • 71
  • 5
2

This may happen, when something is wrong with Startup.cs file. For instance it can be placing interface instead of realization class

services.AddScoped<IService, IService>();

When you need to specify realization class:

services.AddScoped<IService, Service>();
Sergiy Velychko
  • 457
  • 6
  • 6
2

I have .Net 6 application I was getting this issue because I had some errors in Dependency Injection. Best way would be to put the try catch over your CreateWebHostBuilder in Program.cs, either throw the error or Log it anywhere or put a debugger.

I was missing some dependency mapping.

Use this way to find the error:

            try
            {
                Log.Information("Starting Service");
                CreateWebHostBuilder(args).Build().Run();
                return 0;
            }
            catch (Exception ex)
            {
                Log.Fatal(ex, "Terminated");
                return 1;
            }
KushalSeth
  • 3,265
  • 1
  • 26
  • 29
  • 1
    This helped me resolve a application that was failing to start up due to some missing appSettings configuration. Thanks. – uniquelau Sep 04 '22 at 08:41
  • Starting from .Net Core 3, you should use `IHostBuilder` instead of `IWebHostBuilder` – Niksr Apr 01 '23 at 11:09
1

Sometimes you need to refresh the application pool in combination with one of the aforementioned solutions.

Farzad M.
  • 159
  • 3
  • 14
1

I had a project running on Digital Ocean. After a year, I needed to port that project which was running fine on my local Mac and the Digital Ocean to azure. Then I got the 500.30 error I had tried all of the above but with no luck. Finally, in my case, it was that for my project to work with the Digital Ocean I had to make it work in port 8080, I was using the code below to do that.

if (app.Environment.IsDevelopment())
{
    app.Run();
}
else
{
    app.Run("http://0.0.0.0:8080");
}

when at the end delete that code and kept only

app.Run()

everything works just fine. The same is true if you want to deploy the app in IIS.

Aris Skam
  • 106
  • 1
  • 4
1
  • Most often, this issue is caused by a faulty dependency injection in one of your classes.

  • Ensure your interfaces are registered in your startup class properly.

  • Also check your Logger interfaces you inject in your classes, those could cause issues sometimes.

Bernard Oreva
  • 124
  • 1
  • 4
1

Turns out it was UseResponseCompression which was causing HTTP 500.30.

https://learn.microsoft.com/en-us/aspnet/core/performance/response-compression?view=aspnetcore-7.0

juFo
  • 17,849
  • 10
  • 105
  • 142
0

On my end, I found that on Azure, I accidentally chose .NET Core 3.1, whereas I was deploying an app targeting ASP.NET Core 5.0. After changing the version to .NET 5.0 on the Azure App Service, it works.

enter image description here

Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
A SHAHZAD
  • 176
  • 2
0

I found out how to fix this issue. If your project is inside of a folder that has been renamed or moved, that means you need to change the folder and drive for that route. If your project is in the drive d:\, leave that and make a new folder in another drive like e:\ or c:\ and test it again.

Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
  • 4
    Please use proper spelling and punctuation when posting on this site. – General Grievance Jul 26 '21 at 20:54
  • 1
    I’ve made a best effort to clarify the instructions here. I’m not confident that I understood the intent, though, so please review and confirm. This is my area of expertise, yet I’m not entirely clear how this guidance relates to this problem. – Jeremy Caney Jul 27 '21 at 04:38
0

This error message also comes when you try to install the published package to the ISP-hosted shared IIS server or an ISP-hosted Virtual Machine.

  • Deployment mode: Framework-Dependent
  • Target Runtime: Win-x64 or Portable

In my case, when I tried to deploy ASP.NET Core 5 application, it occurred due to not setting the change (read/write/delete) permission to the web application folder for the user group, basically the root folder.

Dush
  • 1,185
  • 26
  • 29
  • How did you give the permission exatly? Publishing it self contained? – AsIndeed Dec 20 '21 at 07:47
  • @AsIndeed, yes I gave them permission to the app. Regarding the next question "Publishing it self-contained?" the answer is above on my answer, read the answer carefully. It is "Framework-Dependent" not "self-contained". Actually, I did not try with "self-contained" deployment mode. – Dush Dec 23 '21 at 23:02
0

Try to change deployment mode into self contained

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 30 '21 at 00:08
0

if your host bundle is 5 and also your app is 5 or your host bundle is 6 and aslo your app is 6

(for check host version :
NetCoreVersion=@Environment.Version
)

then, set this in your publish setting befr publish:

(Deployment mode: self-contained & Target Runtime: Win-x64 or Portable) this option added ~75MB~ necessary files to your published project

مهدی
  • 333
  • 3
  • 6
0

Another possible reason: The app throws an exception at startup, e.g. in a static initializer or the like. In that case, the eventlog does not always show any related entries at all, but the console output will tell.

JensG
  • 13,148
  • 4
  • 45
  • 55
0

**

in .net most: server(host) .net ver > your application .net ver :: server net ver = 6.0.5 <> application ver = 6.0.6 >> not work application ver = 6.0.4 >> ok work :: if ver of .net in each first digit is same "x" (x.0.0) and other digit (0.x.x) in server was lower, you can select self-contained from developmentmode in publishing.

**

<h1>@Environment.Version()</h1>
مهدی
  • 333
  • 3
  • 6
0

I was getting this same error and none of the answers helped me. My scenario was I had multiple sites setup on the server and i had set my WebAPI Core 6 app to run on port 8080 in the bindings. The problem was i had not allowed that port through the firewall on the server. I hope this helps someone else so you dont waste hours on this like i did.

Kevbo
  • 947
  • 9
  • 12
0

Mine was missing a comma in the appsettings.json file, unbelievable.

paul-2011
  • 675
  • 10
  • 27
0

I had the same problem when deploying a site which had been upgraded from dotnet core 3.1 to dotnet 6. Running @uvylight's suggestion revealed that it was complaining about a DLL dependency, and upon investigation the (standard Microsoft) DLL in question had not been updated.

In my case the solution was to change the "Delete existing files" option (in the VS Publish dialogue) to true, which forced it to clear the entire folder on the target server & recopy everything. This took dramatically longer than usual - 17 minutes instead of the usual 1-minute-or-so - but it did the trick, installing the newer versions of all the standard DLLs and resolving the problem. I recommend unticking "Delete existing files" afterwards though.

-1

Struggled with this for a bit. Had some start-up code that relied on information in my config files and I did not set an environment variable in my Azure App Service.

Once I sorted that out all was well.

  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 02 '22 at 12:24
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/32346818) – 5ar Aug 02 '22 at 14:16