Sql-server – SQL Server on Ubuntu – An existing connection was forcibly closed by the remote host after reboot

connectivitysql serverUbuntu

I have been running SQL Server on Ubuntu for a while and everything has been working fine but I rebooted the server and now all connections to SQL Server fail with the error:

A connection was successfully established with the server, but then an error occurred during the login process. 
(provider: SSL Provider, error: 0 - 
An existing connection was forcibly closed by the remote host.) 
(Microsoft SQL Server, Error: 10054)

I have tried uninstalling and reinstalling SQL Server, setting various mssql-conf values (since removed again) etc. but nothing I do makes any difference.

Articles relating to Windows seem to point to it being SSL-related but SSL was not enabled. I did try to enable it and set a certificate but then even though I made permissions to the certificate and private key 777 and chowned to the mssql user/group it just told me it couldn't read it and then SQL Server failed to start up so I removed again.

Can anyone suggest anything I can do to get it working again please as I am out of ideas?

Thanks
Robin

Best Answer

MSSQL expects OpenSSL v1.0 while Ubuntu 18+ uses OpenSSL 1.1, resulting in a OpenSSL version mismatch. The solution is to symlink ssl v1.0 as below:

  1. Stop SQL Server

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

    sudo systemctl edit mssql-server
    
  3. In the editor, add the following lines to the file and save it:

    [Service]
    Environment="LD_LIBRARY_PATH=/opt/mssql/lib"
    
  4. 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
    
  5. Start SQL Server

    sudo systemctl start mssql-server