skip to Main Content

I published my site on plesk, in login form when I enter username and password I get error. I should say that my login form is based on asp.net configuration and roles and users are set there.

System.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: SQL Network Interfaces, error: 26
Error Locating Server/Instance Specified)

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) at
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions
options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo,
DbConnectionPool pool, DbConnection owningConnection,
DbConnectionOptions userOptions) at
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool
pool, DbConnection owningObject, DbConnectionOptions options,
DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) at
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection
owningObject, DbConnectionOptions userOptions, DbConnectionInternal
oldConnection) at
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection
owningObject, DbConnectionOptions userOptions, DbConnectionInternal
oldConnection) at
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection
owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean
allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions
userOptions, DbConnectionInternal& connection) at
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection
owningObject, TaskCompletionSource1 retry, DbConnectionOptions
userOptions, DbConnectionInternal& connection) at
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection
owningConnection, TaskCompletionSource
1 retry, DbConnectionOptions
userOptions, DbConnectionInternal oldConnection, DbConnectionInternal&
connection) at
System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource1 retry, DbConnectionOptions userOptions) at
System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource
1 retry, DbConnectionOptions userOptions) at
System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1
retry) at
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource
1
retry) at System.Data.SqlClient.SqlConnection.Open() at
System.Web.DataAccess.SqlConnectionHolder.Open(HttpContext context,
Boolean revertImpersonate) at
System.Web.DataAccess.SqlConnectionHelper.GetConnection(String
connectionString, Boolean revertImpersonation) at
System.Web.Security.SqlRoleProvider.GetRolesForUser(String username)
at System.Web.Security.Roles.GetRolesForUser(String username) at
RealEstate.login.Button1_Click(Object sender, EventArgs e) in
C:UsersEZ-TECHDocumentsVisual Studio
2010Projects3LayerRealEstateRealEstatelogin.aspx.cs:line 36
ClientConnectionId:00000000-0000-0000-0000-000000000000 Error
Number:-1,State:0,Class:20

6

Answers


  1. There could be several issues causing your error:

    1) Make sure your server name is correct, e.g., no typo on the name.

    2) Make sure your instance name is correct and there is actually such an instance on your target machine. [Update: Some application converts to . If you are not sure about your application, please try both ServerInstance and ServerInstance in your connection string]

    3) Make sure the server machine is reachable, e.g, DNS can be resolve correctly, you are able to ping the server (not always true). Simply open Command Prompt and type “-ping yourservername” if it is a named instance or “-ping yourserverIP” if it is an unnamed instance.

    4) Make sure SQL Browser service is running on the server.

    5) If firewall is enabled on the server, you need to put sqlbrowser.exe and/or UDP port 1434 into exception.

    I had the same issue with an application of mine and it was resolved by 4), enabling the SQL Browsing service on the server.

    Reference and additional information: https://blogs.msdn.microsoft.com/sql_protocols/2007/05/13/sql-network-interfaces-error-26-error-locating-serverinstance-specified/

    Login or Signup to reply.
  2. I had same error, I later figured out that I was using a forward slash (/) instead of backslash () slash in my connection string.

    This was what I was using-:

    Server=(localdb)//mssqllocaldb;
    

    While this was the correct connection string:

    Server=(localdb)\mssqllocaldb;
    
    Login or Signup to reply.
  3. In my case it was intermmitent error, on and off. It was caused by DB server having IP conflict. Hope this will help somebody.

    Login or Signup to reply.
  4. *Localhost Sql server
    *Database name is sample
    *connectionString name is SampleConnectinString

    • Just check for connection string, your error will go

    <connectionStrings>
            <add name="SampleConnectinString" connectionString="Data Source=.SQLEXPRESS; Integrated Security=true;Initial Catalog= sample;" providerName="System.Data.SqlClient" />
    </connectionStrings>
    

    *using connectionstring in ado.net

    string cs = ConfigurationManager.ConnectionStrings["SampleConnectinString"].ConnectionString;SqlConnection con = new SqlConnection(cs);
    
    Login or Signup to reply.
  5. the connection string might be the problem.check once whether you were able to login in sql server in your pc with the connection mentioned in config file.
    FYI:IIf yusing go daddy as host remove the name after colon in host.
    eg:host=198.71.225.113:1433
    use only "data source=198.71.225.113" ignore ":1433"

    Login or Signup to reply.
  6. Use Data source="localhostSQLEXPRESS" instead of Data source=".SQLEXPRESS"

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search