microsoft / homebrew-mssql-release

Other
92 stars 31 forks source link

Can't connect to the server #83

Closed semcha closed 11 months ago

semcha commented 2 years ago
msodbcsql18 18.1.1.1
mssql-tools18 18.1.1.1
sqlcmd -S "HOST" -U "USER" -P "PASS" -d "DATABASE" -C -N -q "select @@version"
Sqlcmd: Error: Microsoft ODBC Driver 18 for SQL Server : TCP Provider: Error code 0x2746.
Sqlcmd: Error: Microsoft ODBC Driver 18 for SQL Server : Client unable to establish connection.
v-chojas commented 2 years ago

Could you give any more information? Was it working before and stopped working(and if so, did you do anything to cause it), is this your first time using it, what OS version, etc?

semcha commented 2 years ago

@v-chojas

I found a solution for Ubuntu 20.04 - add lines to OpenSSL configuration file (/etc/ssl/openssl.cnf):

openssl_conf = default_conf

...

[default_conf]
ssl_conf = ssl_sect

[ssl_sect]
system_default = system_default_sect

[system_default_sect]
MinProtocol = TLSv1.2
CipherString = DEFAULT@SECLEVEL=1

But Ubuntu 20.04 works with OpenSSL 1.1.1 unlike the MacOS brew-version driver which works with OpenSSL 3 and I have not found any way to connect the server : (

semcha commented 2 years ago

The solution for OpenSSL 1.1.1 was found here: https://github.com/microsoft/msphpsql/issues/1112#issuecomment-609972220

v-chojas commented 2 years ago

Are you sure it is a problem with OpenSSL and not e.g. firewall/network connectivity? 0x2746=10054 is a rather generic error (connection reset by peer.)

semcha commented 2 years ago

@v-chojas The problem is that SQL Server versions below 2017 connects using TLS v1.0/1.1 (instead of v1.2) and because of that we need to force TLS v1.2 in OpenSSL configuration. But I haven't found how to do it in OpenSSL 3.

v-chojas commented 2 years ago

SQL 2016 supports TLS 1.2, and versions before that (down to 2008) have an update (KB3135244) which does. Thus I don't think that is the problem here, unless you have actually confirmed it with e.g. packet trace.

hidayat-io commented 1 year ago

i got same problem in macOS, any solution that working ?

v-chojas commented 1 year ago

See comment above, also this is a very generic error so if you don't provide any more details, this is the best we can tell you.

lucasfariasm commented 11 months ago

any solution? same here

v-chojas commented 11 months ago

Open an issue with the details specific to your environment if you strongly believe it's a problem with the driver and eliminated other causes. Network errors are generic and troubleshooting those are outside the scope of this project.