1

I am using Microsoft.EntityFrameworkCore (version 3.1.30) in a .NET Framework 4.8 WPF application to access a remote SQL Server 2016 Express.

On a specific instance I get this error:

Microsoft.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: HTTP Provider, error: 0 - )

The connection string is specified with IP address (not a named instance) and Trust server certificates = True

I can successfully connect if I manually specify the tcp: protocol before IP address

Why does SqlClient try to select HTTP Provider in this case?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Genesio
  • 171
  • 2
  • 13
  • 3
    Does this answer your question? [Force the TCP/IP protocol in connection string](https://stackoverflow.com/questions/4430381/force-the-tcp-ip-protocol-in-connection-string) – Ryan Wilson Nov 07 '22 at 19:39
  • According to [here](https://learn.microsoft.com/en-us/troubleshoot/sql/connect/clients-change-protocols-when-connect-instance): _the protocol order is stored in the ProtocolOrder registry entry under the following registry subkey: `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Client\SNI`_. The following may also be useful: https://stackoverflow.com/a/71199793/10024425 – Tu deschizi eu inchid Nov 07 '22 at 20:05
  • Does this answer your question? [Can't access my SQL Server via C# form application from client device](https://stackoverflow.com/questions/71198996/cant-access-my-sql-server-via-c-sharp-form-application-from-client-device) – Tu deschizi eu inchid Nov 07 '22 at 20:08

0 Answers0