Steps to Reproduce:
Get the error
"mssql: Failed to connect: System.Data.SqlClient.SqlException: 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: TCP Provider, error: 35 - An internal exception was caught) ---> System.AggregateException: One or more errors occurred. (Connection refused 127.0.0.1:1433) ---> System.Net.I
RetryClose
Error"
@yasinguzel have you verified that SQL Server is active on the server\port you're connecting to and there are no firewalls blocking the traffic.
The error message says failed to connect to "127.0.0.1:1433". Is this a SQL on Linux instance running in a local Docker instance? Do you have a way to verify connectivity using an alternate tool such as sqlcmd?
I'm closing this as we haven't received updated information. If you want to reopen please add in the information Karl requested and we can take another look.
I also have this issue when trying to connect localDB from vscode with mssql extension.
[9:51:01 PM] Error connecting to server "sqllocalDB\MyTestingDB". Details: 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)
@sainawkham can you connect from other tools or from your app code? Generally localdb server connections should be in the format (localdb)\MSSqlLocalDb or (localdb)\MyInstance. I verified this works fine for me and would suspect the issue is using sqllocalDB instead of (localdb). Similarly, is MyTestingDb your database name? If that's the case, likely you want to use (localdb)\MSSqlLocalDb as your server name and MyTestingDb as the database name when creating the profile.
@kevcunnane it was ok when i use pipe name instead of servername\instancename. But i'd like to know why i can't connect with name if there is an answer.
Thank & Regards
@sainawkham can you confirm the exact connection string used? You can see it by choosing the "Manage Connections" command and choosing to Edit them - this brings it up in the settings. So long as it doesn't contain a password, could you show it here (since it'll be a localdb instance and therefore not something anyone else could access)?
Also for OS version, which Windows version (10, 8.1, etc.) are you on? Thanks.
@kevcunnane Sorry for my delay reply.
{
"window.zoomLevel": 0,
"mssql.connections": [
{
"server": "np:\\.\pipe\LOCALDB#57B9D9BB\tsql\query",
"database": "",
"authenticationType": "Integrated",
"password": ""
}
]
}
My OS is windows 10.
Thanks & Regards
OK, so that's your connection after using named pipes. When using the server name, what is listed for the "server" option?
hi
im using ubuntu 20.04 and install vscode and mssql plugin
but error run create db command
mssql: Error: Unable to connect using the connection information provided. Retry profile creation?
mssql: Failed to connect: 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: TCP Provider, error: 35 - An internal exception was caught) ---> System.Net.Internals.SocketExceptionFactory+ExtendedSocketException (00000005, 6): No such device or address
at System.Net.Dns.InternalGetHostByName(String hostName)
at System.Net.Dns.GetHostAddresses(String hostNameOrAddress)
at Microsoft.Data.SqlClient.SNI.SNITCPHandle.Connect(String serverName, Int32 port, TimeSpan timeout)
at Microsoft.Data.SqlClient.SNI.SNITCPHandle..ctor(String serverName, Int32 port, Int64 timerExpire, Object callbackObject, Boolean parallel)
at Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction)
at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at Microsoft.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover, SqlAuthenticationMethod authType, SqlAuthenticationProviderManager sqlAuthProviderManager)
at Microsoft.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover)
at Microsoft.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout)
at Microsoft.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance)
at Microsoft.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, Boolean applyTransientFaultHandling, String accessToken, DbConnectionPool pool, SqlAuthenticationProviderManager sqlAuthProviderManager)
at Microsoft.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
at Microsoft.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions)
at Microsoft.Data.ProviderBase.DbConnectionFactory.<>c__DisplayClass40_0.1 _)
at System.Threading.Tasks.ContinuationResultTaskFromResultTask2.InnerInvoke()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection.ReliableSqlConnection.<>c__DisplayClass30_0.<
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.SqlTools.ServiceLayer.Connection.ConnectionService.TryOpenConnection(ConnectionInfo connectionInfo, ConnectParams connectionParams) in D:\a\1\s\src\Microsoft.SqlTools.ServiceLayer\Connection\ConnectionService.cs:line 524
ClientConnectionId:00000000-0000-0000-0000-000000000000`