ODBC - [08001][unixODBC]Could not connect to the server; Could not connect to remote socket immedaitely [ISQL]ERROR: Could not SQLConnect

If you encounter the following error when you test odbc connection with isql

[08001][unixODBC]Could not connect to the server;
Could not connect to remote socket immedaitely
[ISQL]ERROR: Could not SQLConnect

You may have an error in your odbc.ini file. To be specific, you could be using a wrong "key" name for the server or port in your odbc.ini.

Some background. odbc.ini define DSN information in a key-value pair format and the key is vendor specific. Below is an erratic odbc.ini file entry

 [MSSQL2005]
Driver = ODBC Driver 11 for SQL Server
Description = Microsoft SQL ODBC Driver
Server = your_mssql_server_host
Port = 1433
Database =
[POSTGRESQL9] Driver = PostgreSQL9 Driver
Description = Postgresql ODBC Driver
Server = your_postgresql_server_host
Port = 5432
Database = your_database

With the above entry, MSSQL2005 DSN will work but POSTGRESQL9 DSN will fail.

unixODBC isql will return the following if you try to query POSTGRESQL9 DSN

[shell]$ isql -v POSTGRESQL9 your_user your_password
[08001][unixODBC]Could not connect to the server;
Could not connect to remote socket immedaitely
[ISQL]ERROR: Could not SQLConnect

The problem is.... PostgreSQL does not understand

Server = your_postgresql_server_host

The correct syntax is

Servername = your_postgresql_server_host

So, to fix the error, the correct odbc.ini entry is

 [MSQL2005]
Driver = ODBC Driver 11 for SQL Server
Description = Microsoft SQL ODBC Driver
Server = your_mssql_server_host
Port = 1433
Database =
[POSTGRESQL9] Driver = PostgreSQL9 Driver
Description = Postgresql ODBC Driver
Servername = your_postgresql_server_host
Port = 5432
Database = your_database

Comments

Post a Comment

Popular posts from this blog

FFMPEG - Creating timelapse with FFMPEG with JPEG

MP4 File Format Part 1

RTSP - RTP over TCP