We are encountering an intermittent issue where our Windows-based application hangs indefinitely during SQLConnect when connecting to a PostgreSQL server via ODBC.
Environment
PostgreSQL version: 15.0.15.25315
ODBC driver: psqlODBC 16.00.0007
Connection type: ODBC using certificate-based authentication
Deployment: Application and PostgreSQL server both run on the same machine (localhost)
Application Behavior
The application maintains:
Some long-lived persistent connections
A few short-lived connections (3–4) that are opened/closed periodically
Connection pooling is enabled (we also tested with pooling disabled and reduced timeouts—no change)
Configuration
Connection timeout is explicitly set before calling SQLConnect
TCP keepalive parameters are configured
Both settings are visible in PostgreSQL ODBC trace logs
Issue Description
On a subset of systems, intermittently (roughly once a week, sometimes more frequently), the SQLConnect call:
Hangs indefinitely
Does not return or timeout
Observations / Troubleshooting
Initially suspected Microsoft Defender or network filtering:
Added PostgreSQL data directory to exclusions → no improvement
No network filtering/firewall issues observed
Adjusted connection pooling and timeout values → no impact