Error: TCP Provider: Error code 0x2746. During the Sql setup in linux through terminal

I am trying to setup the ms-sql server in my linux by following the documentation https://docs.microsoft.com/pl-pl/sql/linux/quickstart-install-connect-ubuntu?view=sql-server-2017

The SQL server status is Active (Running).

I am getting the following error while executing the command

sqlcmd -S localhost -U SA -P '<YourPassword>'

Error:

Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : TCP Provider: Error code 0x2746. Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Client unable to establish connection.

I also tried by giving the command

sqlcmd -S 127.0.0.1 -U SA -P '<YourPassword>' 

But the same error is displayed. When I tried the wrong password it also displays the same error.


Solution 1:

[UPDATE 17.03.2020: Microsoft has released SQL Server 2019 CU3 with an Ubuntu 18.04 repository. See: https://techcommunity.microsoft.com/t5/sql-server/sql-server-2019-now-available-on-ubuntu-18-04-supported-on-sles/ba-p/1232210 . I hope this is now fully compatible without any ssl problems. Haven't tested it jet.]

Reverting to 14.0.3192.2-2 helps.

But it's possible to solve the problem also using the method indicated by Ola774, not only in case of upgrade from Ubuntu 16.04 to 18.04, but on every installation of SQL Server 2017 on Ubuntu 18.04.

It seems that Microsoft now in cu16 messed up with their own patch for the ssl-version problems applied in cu10 (https://techcommunity.microsoft.com/t5/SQL-Server/Installing-SQL-Server-2017-for-Linux-on-Ubuntu-18-04-LTS/ba-p/385983). But linking the ssl 1.0.0 libraries works.

So just do the following:

  1. Stop SQL Server

    sudo systemctl stop mssql-server 
    
  2. Open the editor for the service configuration by

    sudo systemctl edit mssql-server 
    

This will create an override for the original service config. It's correct that the override-file, or, more exactly "drop-in-file", is empty when used the first time.

  1. In the editor, add the following lines to the file and save it:

    [Service]
    Environment="LD_LIBRARY_PATH=/opt/mssql/lib" 
    
  2. Create symbolic links to OpenSSL 1.0 for SQL Server to use:

    sudo ln -s /usr/lib/x86_64-linux-gnu/libssl.so.1.0.0 /opt/mssql/lib/libssl.so 
    sudo ln -s /usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0 /opt/mssql/lib/libcrypto.so 
    
  3. Start SQL Server

    sudo systemctl start mssql-server 
    

Solution 2:

If you are having issues with the client on Debian 10 with OpenSSL1.1.1 the fix is to revert to the previously default weaker key length. To do so:

Modify /etc/ssl/openssl.cnf config file as follows (fyi see known issues with OpenSSL 1.1.1 in Debian 10 below):

Change the last line from CipherString = DEFAULT@SECLEVEL=2 to CipherString = DEFAULT@SECLEVEL=1

https://github.com/microsoft/msphpsql/issues/1021

https://wiki.debian.org/ContinuousIntegration/TriagingTips/openssl-1.1.1