Forum Discussion
SQL server connection
KatiS2285 wrote:How could I fix it?
How could we guess/suggest without any error message?
- KatiS2285Jul 10, 2023Copper Contributor
Good morning
Here is the error
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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
08:49:02 at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling, SqlAuthenticationProviderManager sqlAuthProviderManager)
08:49:02 at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
08:49:02 at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
08:49:02 at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
08:49:02 at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
08:49:02 at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
08:49:02 at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
08:49:02 at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
08:49:02 at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
08:49:02 at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
08:49:02 at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
08:49:02 at System.Data.SqlClient.SqlConnection.Open()when in Web.config, the provider name is {providerName="System.Data.SqlClient"}
Thank you
- olafhelperJul 11, 2023Bronze Contributor
Verify that the instance name is correct and that SQL Server is configured to allow remote connections.KatiS2285 , as the message says.
See Troubleshoot connectivity issues in SQL Server - SQL Server | Microsoft Learn
- Jul 10, 2023
You should check "SQL Server configuration manager--> protocols for mssqlserver --> tcp/ip" it must be enabled. After enabling restart the service
And also you may check the status of Windows firewall on database server. It must be disabled or allowed for SQL server ports (1433)