Ubuntu 22.04 Cannot Connect To SQL Server Error Code 0x2746

Dolly Aswin
1 min readJan 22, 2023

--

In my previous post I wrote about Ubuntu 20.04 cannot connect to Microsoft SQL Server. And I still got same problem in Ubuntu 22.04.

dolly@ubuntu:~$ sqlcmd -S <ms-sql-server> -U SA -P '<password>'
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : TCP
Provider: Error code 0x2746.

By default Ubuntu 22.04 use OpenSSL 3.0.2. And based on my experience before, OpenSSL need to be downgraded or upgraded. I tried downgraded OpenSSL to 1.1.1s and 1.1.1k but still not works.

After searched solutions for this problem, finally I found this

Based on that answer, the actual problem was on SECLEVEL. OpenSSL 3.0 changed the default behavior of SECLEVEL. To make Ubuntu 22.04 able to connect to Microsoft SQL Server, just need to adjust the SECLEVEL to 0 instead of 1 at /etc/ssl/openssl.conf .

[system_default_sect]
CipherString = DEFAULT:@SECLEVEL=0

Now, I can connect to SQL Server using Ubuntu 22.04. And I hope this post can save your time! Because on that time, I spent much hours to fix this problem.

--

--

Dolly Aswin

Founder aqilix.com. Build and delivery high-quality software solutions 👉🏻 About me: linkedin.com/in/dollyaswin/