Search code examples
.netsql-serveriis

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


I know that this question have been asked a lot, but none of the answers helped me.

What's happening is that I'm publishing my .net 5 application on IIS on an Azure VM. The problem is when connecting to database server on the VM.

Using an Azure SQl Server with the following connection string, is working normally:

Server=tcp:serverName.database.windows.net,1433;Initial Catalog=database;Persist Security Info=False;User ID=username;Password=Password;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;

But using a connection string for a SQL Server that existing on the VM such as the following:

Server=ACS;Initial Catalog=database;Persist Security Info=False;User ID=username;Password=Password;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;

Is causing the following error:

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

Anyone have any idea what's happening?? I think it's something related to security, permissions on the SQL Server installed on the VM machine. Or that I should add a port number to the connection string.


Solution

  • By default SQL Server is installed with self-signed X.509 certificates. Unless you've installed your own CA-signed certificate, or you've exported the public key and added it to your Trusted Roots store, you'll probably want to use TrustServerCertificate=True; instead.