[freetds] tds7_get_instance_port timed out

Gregor at HostGIS gregor at hostgis.com
Sat Mar 20 00:33:02 EDT 2010

Hey guys. I'm extensively familiar with MySQL and PostgreSQL, but 
connecting to MSSQL 2008 from Linux/PHP has me stumped.

My specific PHP code is this simple line:

$db = 
'user', 'pass');

The result is "Unable to connect to server"

Client platform:
PHP 5.2.13
Mostly PHP CLI for testing, will be Apache 2.0
Slamd64 Linux
FreeTDS, not sure how to find the exact version but was the latest 
stable about 3 weeks ago

MS SQL Server:
SQL Server 2008
on a Amazon EC2

The FreeTDS log shows this:

21:13:03.249137 23593 (net.c:836):tds7_get_instance_port(, 
21:13:04.248694 23593 (net.c:905):tds7_get_instance_port: timed out on 
try 0 of 16
(... and so on...)
21:13:19.731750 23593 (net.c:974):instance port is 0
21:13:19.731764 23593 (login.c:418):invalid port number

I have verified via 'telnet' that I can connect to port 1433; not a 
firewall thing at that level.

I have seen vague clues about the instance name being important, and 
some mentions that 1433 isn't the TCP port for the instance. Can someone 
explain that to me? It may be relevant that the MS SQL is on a Amazon 
EC2 instance, which has firewalls beyond the Windows Firewall. I cannot 
for instance telnet to port 25 and properly get a Connection Refused.

HostGIS, Open Source solutions for the global GIS community
Greg Allensworth - SysAdmin, Programmer, GIS Person, Security
    Network+   Server+   A+   Security+   Linux+
    PHP   PostgreSQL   MySQL   DHTML/JavaScript/AJAX

"No one cares if you can back up — only if you can recover."

More information about the FreeTDS mailing list