Unable to connect: Adaptive Server is unavailable or does not exist

Elisa picture Elisa · May 6, 2013 · Viewed 25.6k times · Source

While trying to connect remote SQL Server:

$tsql -S localhost -U myuser

I got error like:

locale is "en_US.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
Error 20009 (severity 9):
    Unable to connect: Adaptive Server is unavailable or does not exist
    OS error 61, "Connection refused"
There was a problem connecting to the server

The output of $tsql -C is as below:

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

I have created tunnel for remote server like:

$ssh -L 1433:db_server:1433 user@mid_server

This forward the local port 1433 to db_server. I tested. My ssh tunnel works because I can connect to database using Navicat (localhost on 1433). I can telnet localhost on port 1433.

Answer

Elisa picture Elisa · Jul 18, 2013

I kinda get it worked by modifying freetds.conf

from

[global]
    # TDS protocol version
;   tds version = 4.2

to

[global]
    # TDS protocol version
tds version = 7.0