Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Read from the server failed when trying to connect to sql-azure from tsql

I'm trying to connect to SQL-Azure from Ubuntu 12.04.

I've compiled freeTds-0.91 with openssl and libiconf

tsql -H XXXXXXXX.database.windows.net -U Username -D DatabaseName -p 1433 -P Password

I try connect using the above statement and I get this error:

locale is "en_ZA.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
Default database being set to DatabaseName
Error 20004 (severity 9):
    Read from the server failed
    OS error 104, "Connection reset by peer"
Error 20002 (severity 9):
    Adaptive Server connection failed
There was a problem connecting to the server

My tsql -C output:

Compile-time settings (established with the "configure" script)
                        Version: freetds v0.91
         freetds.conf directory: /usr/local/etc
 MS db-lib source compatibility: no
    Sybase binary compatibility: no
                  Thread safety: yes
                  iconv library: yes
                    TDS version: 5.0
                          iODBC: no
                       unixodbc: no
          SSPI "trusted" logins: no
                       Kerberos: no

I can't seem to find any information on what is causing and how to resolve this issue.

Any help will be much appreaciated.

like image 792
Martinffx Avatar asked Jul 30 '12 12:07

Martinffx


People also ask

Can't connect to Azure SQL Server?

Steps to resolve persistent connectivity issues Set up firewall rules to allow the client IP address. On all firewalls between the client and the Internet, make sure that port 1433 is open for outbound connections. Review Configure the Windows Firewall to Allow SQL Server Access for additional pointers.

Can't connect to Azure SQL managed instance?

If you are unable to connect to SQL Managed Instance from an Azure virtual machine within the same virtual network but a different subnet, check if you have a Network Security Group set on VM subnet that might be blocking access.

How do I fix SQL Server Error 53?

User Action. Make sure that you have entered the correct server name on the client, and that you can resolve the name of the server from the client. To check TCP/IP name resolution, you can use the ping command in the Windows operating system.


3 Answers

The error is caused by the use of the wrong version of TDS.

To resolve just specify the TDS version before the tsql command:

TDSVER=8.0 tsql -H XXXXXXXX.database.windows.net -U Username -D DatabaseName -p 1433 -P Password
like image 83
Martinffx Avatar answered Dec 28 '22 23:12

Martinffx


in freetds.conf

[servername] 
host = ipAddress
port = 1433
tds version = 8.0

for checking freetds connection
===============================

$tsql -S servername -U username 
password
like image 21
the-run Avatar answered Dec 29 '22 01:12

the-run


Is your IP address whitelisted by the database server? If not, you won't be able to connect.

like image 44
Paul Avatar answered Dec 28 '22 23:12

Paul