---
title: "Troubeshooting SQL Server ODBC Connection Issues"
description: "SQL Server ODBC connection issues occur when the driver library is missing or misconfigured. Resolving this involves installing the correct Microsoft ODBC driver and setting necessary environment variables properly."
url: "https://docs.itrsgroup.com/docs/faq/geneos/13947833828125-geneos-troubeshooting-sql-server-odbc-connection-issues/index.html"
---
## Related to

Can't open lib 'ODBC Driver 17 for SQL Server',  [unixODBC][Driver Manager]

### Problem

#### Unable to establish connection to an MSSQL server using ODBC driver

This is apparent in the Active Console, where the database *connectionStatus* will show as *Not Connected*, and the below error will be seen in the gateway log file.

```
There was a problem connecting => db error msg: 01000 [unixODBC][Driver Manager]
Can't open lib 'ODBC Driver 17 for SQL Server' : file not found, db error code: 0 (type: DBMSAPI) [0] 01000 [unixODBC][Driver Manager]
Can't open lib 'ODBC Driver 17 for SQL Server' : file not found DBMSAPI
```

### Possible Cause(s)

1. Microsoft OBDC driver library not installed
2. **Gateway unable to find ODBC library**
3. OBDC Library dependencies not satisfied
4. **Incompatible Gateway/OS installation**

### Possible Solution(s)

#### **Install the Microsoft ODBC library**

This will involve installing the correct Microsoft repository configuration, the library and any dependencies. You can find detailed installation instructions on the Microsoft website for various Linux distributions.
[Microsoft ODBC Linux installation instructions](https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server#17)

#### **Gateway unable to find ODBC library**

The following environment variables need to be initialised, as in the example below, in order for the ODBC library to be found. This would be best done in the gateway startup script, or can be set in the user's shell environment.

SQLSERVER\_LIB=/opt/microsoft/msodbcsql17/lib64
LD\_LIBRARY\_PATH=${SQLSERVER\_LIB}:.:${LD\_LIBRARY\_PATH}
ODBCHOME=${SQLSERVER\_LIB}
ODBCSYSINI=${SQLSERVER\_LIB}
ODBCINSTINI=odbcinst.ini
GENEOS\_MSSQL\_DRIVER='ODBC Driver 17 for SQL Server'

#### **Verify ODBC Library dependencies**

If a library that is a dependency of libmsodbcsql is not present, it may appear that libmsodbcsql is missing, as the same error message will appear in the log.

You can check library dependencies with the *ldd* command as shown below.

The example below shows a missing dependency, (*libpcre2-8*), that would lead to the *'Can't open lib ODBC Driver 17 for SQL Server'* error.

```
## ldd /opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.10.so.4.1
        linux-vdso.so.1 (0x00007ffff687c000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00007f05566ca000)
        librt.so.1 => /lib64/librt.so.1 (0x00007f05564c2000)
        libodbcinst.so.2 => /lib64/libodbcinst.so.2 (0x00007f05562ae000)
        libkrb5.so.3 => /lib64/libkrb5.so.3 (0x00007f0555fc3000)
        libgssapi_krb5.so.2 => /lib64/libgssapi_krb5.so.2 (0x00007f0555d6e000)
        libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f05559d9000)
        libm.so.6 => /lib64/libm.so.6 (0x00007f0555657000)
        libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f055543f000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f055521f000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f0554e5a000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f0556cd9000)
        libltdl.so.7 => /lib64/libltdl.so.7 (0x00007f0554c50000)
        libk5crypto.so.3 => /lib64/libk5crypto.so.3 (0x00007f0554a39000)
        libcom_err.so.2 => /lib64/libcom_err.so.2 (0x00007f0554835000)
        libkrb5support.so.0 => /lib64/libkrb5support.so.0 (0x00007f0554624000)
        libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x00007f0554420000)
        libcrypto.so.1.1 => /lib64/libcrypto.so.1.1 (0x00007f0553f36000)
        libresolv.so.2 => /lib64/libresolv.so.2 (0x00007f0553d1e000)
        libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f0553af3000)
        libz.so.1 => /lib64/libz.so.1 (0x00007f05538db000)
        libpcre2-8.so.0 => not found
```

#### **Incompatible Gateway/OS installation**

There are different versions of Geneos software built for EL7, EL8, EL9, with specific library dependencies, in particular openssl and libcurl.

It is vital that the software matches the intended installation platform. e.g.

- geneos-gateway-6.4.0-**el8**-linux-x64.tar.gz  - suitable for Enterprise Linux 8
- geneos-gateway-6.4.0-**el9**-linux-x64.tar.gz  - suitable for Enterprise Linux 9

## Related Articles

- [Database Logging Troubleshooting](https://docs.itrsgroup.com/docs/geneos/current/processing/data-access-and-publishing/geneos_dblogging_tr/index.html#TroubleShooting)


