Hi rosnaib11,
It was notting related with ubuntu environment, it was SQL Server setting.
On my case, TCP dynamic ports was enabled on SQL Server settings.
You need to set this port to your SQL connection string. On my case I am using Laravel, I needed to setup port 49300 to my connection and thats it. If not, it will try to use default port setting (1433)
Hope this helps…
`
‘sqlsrvconnection’ => [
'driver' => 'sqlsrv',
'host' => env('PHC_HOST', 'localhost'),
'database' => env('PHC_DATABASE_PRODUCTION', 'forge'),
'username' => env('PHC_USERNAME', 'forge'),
'password' => env('PHC_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'port' => 49300
],`
So I’ve been spending quite some time now to fix this issue.
While installing SQL Server 2019 I have this error:
I already filled in the downloaded file for Microsoft ODBC Driver 17 from here :https://learn.microsoft.com/en-us/sql/connect/odbc/download-odbc-driver-for-sql-server?view=sql-server-ver15
When I click ‘OK’ I get the following error:
Honestly I am completely clueless what to do.
Been spending the entire day just to get a local database running..
Any ideas?
What info do you need?
- Installation of SQL Server 2019
- Windows 10 v 10.0.17763 Build 17763
asked Apr 17, 2020 at 15:38
2
In my case, Microsoft ODBC Driver 17 for SQL Server was already installed, but SQL Server 2019 install said it could not find it. The resolution was to Uninstall Microsoft ODBC Driver 17 for SQL Server, and let ISO install it’s own.
answered Dec 3, 2020 at 17:23
2
Hi folks,
I have 4 x SQL Servers (2xSQL2012, 2xSQL2019).
Thy are unable to connect to our legacy SQL Servers, resulting in the errors below from various tests.
I have installed the same providers as our other SQL Servers that can successfully connect to our legacy SQL Servers.
Ports tests fine from the New SQL Servers. No firewall blocking (internal servers). Using SQL authentication for tests.
Any helpful constructive dialogue appreciated.
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : [Microsoft][ODBC Driver 17 for SQL Server]SSL Provider: An existing connection was forcibly closed by the remote host.
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : [Microsoft][ODBC Driver 17 for SQL Server]Client unable to establish connection.
[Microsoft][ODBC Driver 13 for SQL Server]SSL Provider: An existing connection was forcibly closed by the remote host. [Microsoft][ODBC Driver 13 for SQL Server]Client unable to establish connection
[ODBC Driver 17 for SQL Server]SSL Provider: An existing connection was forcibly closed by the remote host.
[ODBC Driver 17 for SQL Server]Client unable to establish connection
HResult 0x2746, Level 16, State 1
TCP Provider: An existing connection was forcibly closed by the remote host.
Sqlcmd: Error: Microsoft SQL Server Native Client 10.0 : Client unable to establish connection.
TCP Provider: An existing connection was forcibly closed by the remote host.
OLE DB provider «MSOLEDBSQL» for linked server «<SERVERNAME_REMOVED>» returned message «Client unable to establish connection». (Microsoft SQL Server, Error: 10054)
I have installed Sql Server 2019 Developer Edition and mssql-tools on my Ubuntu 20.04 minimal.
I can connect to my localhost with no issue, but when I want to remote to another sql server:
sqlcmd -S <server> -U <username> -P <password>
I face this error:
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : SSL Provider: [error:1425F102:SSL routines:ssl_choose_client_version:unsupported protocol].
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Client unable to establish connection.
I has this issue once in Debian 10, and also search the net for solution, so after that I change my openssl.conf manually (su permission needed):
nano /etc/ssl/openssl.cnf
and add these to my file:
-
ess_cert_id_alg = sha1under the[tsa_config1]heading -
openssl_conf = default_confnear the top -
the following at the end:
[default_conf]
ssl_conf = ssl_sect
[ssl_sect]
system_default = system_default_sect
[system_default_sect]
MinProtocol = TLSv1.0
CipherString = DEFAULT@SECLEVEL=1
I know that MinProtocol and CipherString are normally set to TLSv1.2 and DEFAULT@SECLEVEL=2, but as I mentioned once in my Debian 10, I edited my openssl.conf and change TLSv1.2 to TLSv1.0 and DEFAULT@SECLEVEL=2 to DEFAULT@SECLEVEL=1 and my connection fixed, but in Ubuntu 20.04 minimal not only there wasn’t these lines, but also when I insert these manually again I face the same error:
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : SSL Provider: [error:1425F102:SSL routines:ssl_choose_client_version:unsupported protocol].
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Client unable to establish connection.
my opnessl version is:
OpenSSL 1.1.1f 31 Mar 2020
I also downgrade my openssl once to 1.0 but it didn’t work either!
I couldn’t find anything else so I came here to ask for help, appreciate your help.
Issue
I used to use this sqlcmd to run my query and it is working fine up until I ran it in a different computer. I got the following error:
>sqlcmd -S localhost -d master -E -h -1 -i my-query.sql Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Named Pipes Provider: Could not open a connection to SQL Server [2]. . Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login timeout expired. Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online..
Solution
Specify the exact SQL Server named instance instead of using localhost. So, I change from sqlcmd -S localhost…tosqlcmd -S .SQLEXPRESS…`.
About the author
Xuan Ngo is the founder of OpenWritings.net. He currently lives in Montreal, Canada. He loves to write about programming and open source subjects.




