msphpsql: TCP Provider: Error code 0x2746. Client unable to establish connection.
I am using ubuntu 16.04, php7.1 and have followed the php7.1 specific installation instructions on here: https://github.com/Microsoft/msphpsql/tree/PHP-7.0-Linux#install.
I am trying to connect to a named instance through its port number. Using pdo_sqlsrv, sqlsrv and via command line (with the sqlcmd tool like in the tutorial) I always get the same error:
user@webserver:/# sqlcmd -d database -S databaseserver,50000 -U sa -P password -Q 'select top 1 id from table'
Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : TCP Provider: Error code 0x2746. Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : Client unable to establish connection.
I know that the database server is found: when I change the port to a not used port I get a login timeout.
In the server logs of the SQL server I find this error:
Length specified in network packet payload did not match number of bytes read; the connection has been closed. Please contact the vendor of the library. [CLIENT: webserver_ip]
When executing the same command from my windows PC command line on the same network it does work.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 41 (12 by maintainers)
https://stackoverflow.com/a/57343207/2242402 solved it for me - Need to revert to previous sql server version
Why is this closed? I need to connect to a remote SQL Server and am getting the same error. I cannot change anything on the server. Downgrading openssl is not really an option. Running Ubuntu 20.4.
I started to have this error after upgrading my Linux server packages on (Centos 7). Previously everything worked fine. I can’t use php7.1-sybase driver due to some limitations with binary data fields. Is there any way to make this work with pdo_sqlsrv?
My error message is following:
My freedback, solved reinstalled ubuntu and sql server and using this guide. I’ve run several sqlcmd commands and okay so far. https://www.microsoft.com/en-us/sql-server/developer-get-started/php/ubuntu/
Ok just figured it out. Needs to register the mssql-server 2017 repository
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -sudo add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/16.04/mssql-server-2017.list)"Figured out By : https://stackoverflow.com/questions/57265913/error-tcp-provider-error-code-0x2746-during-the-sql-setup-in-linux-through-te/57343207#57343207
Yeah that worked, as a workaround. When will be released a complete fix?
I can confirm that lack of TLS 1.2 support in Windows Server 2003 is the issue.
I tested with a server that has the same SQL version but Windows Server 2008 and that works.
It is impractical to upgrade windows on our servers now, but we managed to resolve the issue for now by switching to the php7.1-sybase driver and using pdo_dblib.
@plabbett with Ubuntu 20.04 and above you can’t connect to a server prior to SQL Server 2017 without a workaround.
Please see this related issue
as jafarulla15 mentioned , https://stackoverflow.com/questions/57265913/error-tcp-provider-error-code-0x2746-during-the-sql-setup-in-linux-through-te/57343207#57343207 resolves the issue but in my case I needed to link both libs in /lib folder , instead of /usr/lib.
@david-puglielli Yes there is no repository for 18.04 and yes with last update (14.0.3223.3-15) i couldn’t connect to the mssql, but service was running. I thought it was openssl or other ssl related package problem, because microsoft dev team said that sql 2017 won’t be installed on ubuntu 18 because of ssl package dependency, after announced on this https://blogs.msdn.microsoft.com/sql_server_team/installing-sql-server-2017-for-linux-on-ubuntu-18-04-lts/ i installed it on my ubuntu 18 vps , but with last update, also a dist package update i think, this problem occured. i had to downgrade to ubuntu 16, everything is ok right now. you should (and me also) wait for an official release to use on ubuntu 18.
@vedmant , were you able to connect with sqlcmd? Can you try
strace -tt sqlcmd -S <servername> -U <username> -P <password>? Also, is it possible for you to upgrade you Server? Another thing you may want to try is to update to ODBC 17 as mentioned in #468.Hi. I’m the sysadmin supporting @Inwerpsel on this issue. I can confirm it’s not a firewall issue. I did some network traces, and the TCP connection does get established. There some initial handshake, but pretty quickly the connection is dropped. I assume it is a protocol mismatch.