Cannot connect to SQLExpress

Cannot connect to SQLExpress



My C# app has problems connecting to my SQLServerExpress instance.


SQLServerExpress



Running the app using localhostSQLExpress or <servername>SQLExpress in my connection string works locally on the server but not from other hosts in the network.


localhostSQLExpress


<servername>SQLExpress


1433


AllowRemoteConnection


true



I still get an SqlException saying:


SqlException


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.
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)
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, TaskCompletionSource`1 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, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
at System.Data.SqlClient.SqlConnection.Open()



Is there anything else I need to check ?



Update #1:


PS C:Windowssystem32> Get-Process -Name sqlservr
| Select-Object -ExpandProperty ID
| ForEach-Object select LocalAddress, LocalPort, RemoteAddress, RemotePort, State


LocalAddress : ::
LocalPort : 58956
RemoteAddress : ::
RemotePort : 0
State : Listen

LocalAddress : ::
LocalPort : 1433
RemoteAddress : ::
RemotePort : 0
State : Listen

LocalAddress : 0.0.0.0
LocalPort : 58956
RemoteAddress : 0.0.0.0
RemotePort : 0
State : Listen

LocalAddress : 0.0.0.0
LocalPort : 1433
RemoteAddress : 0.0.0.0
RemotePort : 0
State : Listen



This question came from our site for computer enthusiasts and power users.





I'm voting to close this question as off-topic because questions should be written in English which includes error messages.
– Security Hound
Aug 22 at 11:16





@Ramhound imo it's still more than clear what my problem is. but for your sake of heart i googled the translated message
– Felix D.
Aug 22 at 11:20





It wasn't for "my sake of heart", questions here at Superuser, are expected to be in English. The error indicates the server is not reachable. This sounds like a pure programming issue which would be out of scope here at Superuser (which is the close reason I selected).
– Security Hound
Aug 22 at 12:12





@Ramhound the question itself is written in english.. however the question itself should be good now. I choose SU over SO because is is working on the server itself (as written in the question) so the code is fine ! It has to be some sort of configuration mistake - I guess SU is the correct one for that (or am I wrong ?)
– Felix D.
Aug 22 at 12:26





Can you add to the question the output of the following Powershell command from the "server": Get-Process -Name sqlservr | Select-Object -ExpandProperty ID | ForEach-Object select LocalAddress, LocalPort, RemoteAddress, RemotePort, State
– HelpingHand
Aug 22 at 21:09


Get-Process -Name sqlservr | Select-Object -ExpandProperty ID | ForEach-Object select LocalAddress, LocalPort, RemoteAddress, RemotePort, State




1 Answer
1



Try this:



Go to SQL server configuration Manager (Win+R => SQLServerManager10.msc or SQLServerManager.msc)



Click SQL Network Services and navigate to concerned Server.



Enable TCP/IP Protocol for IP Based Conn (or) Named pipes for named connections(using server name)



Restart the SQL Server and Check






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Edmonton

Crossroads (UK TV series)