Error 20009 (severity 9):Unable to connect: Adaptive Server is unavailable or does not exist OS error 111, "Connection refused"

Vishnu picture Vishnu · Jun 13, 2013 · Viewed 24.1k times · Source

while trying to connect to remort mssql server by command

tsql -S SQLEXPRESS  -U sa

passwod :sa it throws error as Error 20009 (severity 9):Unable to connect: Adaptive Server is unavailable or does not exist OS error 111, "Connection refused"

Steps i followed /etc/freetds/freetdsconf.conf

[SQLEXPRESS]
host = 192.168.1.9
port = 1433
tds version = 8.0
client charset = UTF-8

/etc/odbcinst.ini
[FreeTDS]
Description     = TDS driver (Sybase/MS SQL)
Driver          =/usr/lib/i386-linux-gnu/odbc/libtdsodbc.so
Setup           =/usr/lib/i386-linux-gnu/odbc/libtdsS.so
CPTimeout       =
CPReuse         =
FileUsage       = 1


etc/odbc.ini
[SQLEXPRESS]
Driver      = FreeTDS
Description = ODBC connection via FreeTDS
Trace       = No
Servername  = 192.168.1.9
Database    = cakephp_results
Port        = 1433
UID         = sa
PWD         = sa
ReadOnly    = No

Answer

Derrick picture Derrick · Aug 27, 2013

In your odbc.ini file change 'Servername = ' to 'Server = '. Then remove the UID, PWD and ReadOnly lines from that file temporarily. You may want to remove them altogether and pass in the credentials from your application.

Then, be sure that your MSSQL DB is allowing connections through port 1433, that SQL Server is not blocking the incoming server's IP address, and that you have the correct password.

Also, if that doesn't work, review these troubleshooting instructions: