Can't connect to containerized localhost Postgres on a domain joined Mac
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 48/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- macos, postgresql
- Área
- database
Línea de trabajo
Start by reading the connection profile schema and Advanced Connection Settings implementation, which the issue identifies as places to expose gssencmode; compare how the existing SSL options are handled. Reproduce with the bundled libpq and the described PGGSSENCMODE=disable workaround. Done means the connection avoids timing out on the stalled GSS exchange, with the setting available to users and covered by an appropriate test.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Local connections time out on domain-joined macOS machines (gssencmode=prefer + GSS-capable server)
Describe the bug
The extension cannot connect to PostgreSQL on localhost (or any GSS-capable server) from a domain-joined corporate Mac with active Kerberos tickets. The connection fails after connect_timeout seconds with:
Connection error for host=localhost port=5432 dbname=postgres user=postgres password=*****
connect_timeout=15 client_encoding=utf8 sslmode=prefer: connection timeout expired
Extension host log:
Error connecting to server "localhost". Details: Could not connect to 'localhost' within 15 seconds.
Failed to initialize object explorer session: couldn't get a connection after 15.00 sec
Every other client (DBeaver, node-postgres, the ckolkman.vscode-postgres extension, raw sockets) connects to the same server in milliseconds. Azure DB connections from the same extension and same tools-service process also work.
Root cause: the tools service's bundled libpq runs with the default gssencmode=prefer. The extension's conninfo never sets gssencmode. When the server advertises GSS encryption support (responds G to a GSSENCRequest), libpq starts a Kerberos GSSAPI exchange against the machine's AD domain. On corporate machines the KDC is often unreachable or black-holed over the VPN path, the exchange stalls, and the connect timeout expires. libpq only falls back to SSL/plaintext if the GSS attempt errors out quickly — a stalled KDC exchange consumes the entire timeout.
This is likely the real cause of #78, currently attributed to macOS Sequoia Local Network privacy restrictions. Every report there matches this profile: corporate-managed, domain-joined Macs, local/LAN targets, 127.0.0.1/::1/localhost all failing identically, other tools working — including from VS Code's own integrated terminal. The GSS attempt happens regardless of loopback form, and granting VS Code Local Network permission changes nothing.
To Reproduce
-
Join a Mac to an AD domain with valid Kerberos tickets (
klistshows a TGT) and a network path where the KDC is unreachable or drops packets (corporate VPN). -
Run PostgreSQL locally in a container using an official image with GSSAPI support (verified with
postgres:18-alpine). These images answerGto aGSSENCRequesteven with no keytab, so a GSS attempt can never complete:printf '\x00\x00\x00\x08\x04\xd2\x16\x30' | nc -w 5 127.0.0.1 5432 | xxd 00000000: 47 G -
In VS Code with this extension, create a connection profile for
host=localhost port=5432with default settings. -
Connect. It hangs for exactly
connect_timeout(15 s) and fails withconnection timeout expired.
Verified with the extension's own bundled libpq.5.dylib (pgsqltoolsservice/v3.7.4/OSX/.../psycopg_binary/.dylibs/libpq.5.dylib): a raw PQconnectdb() with the extension's exact conninfo blocks in the GSS/Kerberos exchange and does not return within 60 seconds. No password is needed to reproduce — with the GSS path removed it fails fast (in ~0.01 s) at fe_sendauth: no password supplied, which is the expected auth-stage failure.
Expected behavior
The connection succeeds, or at minimum libpq falls back to SSL/plaintext instead of burning the whole timeout on a stalled GSS exchange. Ideally:
- Expose
gssencmode(disable/prefer/require) in the connection profile schema and Advanced Connection Settings drawer, alongside the SSL options. - Consider defaulting to
gssencmode=disablefor local servers (loopback / private addresses from the local-install and Docker/Podman flows). A local or containerized Postgres on a dev machine won't authenticate via Kerberos; attempting GSS against it can only produce a fallback or a timeout. This would fix connections for all domain-joined corporate users with zero configuration. - At minimum, document the
PGGSSENCMODE=disableworkaround in the troubleshooting guide, since the connection dialog offers no way to set it.
Workaround
launchctl setenv PGGSSENCMODE disable # fully quit and restart VS Code
Resets on reboot. Alternatively export PGGSSENCMODE=disable in the shell profile and launch VS Code via the code CLI so the tools service inherits it. This only works because the extension never sets gssencmode in its conninfo — if a future version starts setting it, the env var is silently ignored (libpq precedence: conninfo value > env var > compiled default).
Screenshots
N/A.
VS Code version
VS Code 1.145.0
macOS (Apple Silicon), AD-bound to corporate domain (valid TGT), Cisco AnyConnect, Jamf, CrowdStrike
(Paste full Code -> About Visual Studio Code output when filing.)
Extension: ms-ossdata.vscode-pgsql 1.32.1 (stable)
Tools service: ossdbtoolsservice v3.7.4 (bundled psycopg 3.2.4, psycopg_pool 3.2.6, bundled libpq.5.dylib)
Server: postgres:18-alpine in a Podman container, published on 0.0.0.0:5432
Extension Logs
Log showing the failure and conninfo (no gssencmode present):
Connection error for host=localhost port=5432 dbname=postgres user=postgres password=*****
connect_timeout=15 client_encoding=utf8 sslmode=prefer: connection timeout expired
Error connecting to server "localhost". Details: Could not connect to 'localhost' within 15 seconds.
Failed to initialize object explorer session: couldn't get a connection after 15.00 sec
Additional context
- Verified with the extension's bundled libpq: adding
gssencmode=disableto the same conninfo reaches the auth stage in ~0.01 s. Identical result withhost=127.0.0.1, so it is not IPv4/IPv6/localhost-resolution related. - Non-GSS protocol path verified against the live server via raw sockets (sequential and 5 concurrent, IPv4 and IPv6, through the container runtime's port forwarder):
SSLRequest→N,StartupMessage→ SCRAM challenge, single-digit milliseconds every time. - Azure DB connections from the same tools-service process succeed because GSS realm discovery for the Azure hostname fails fast and libpq falls back to SSL (~550 ms, per
pgsql-tools.log). A stalled KDC exchange does not fail fast — that's the difference. - libpq docs on GSSENCMODE / PGGSSENCMODE: default is
prefer; env varPGGSSENCMODEis honored only when the conninfo doesn't set the parameter. - Related: #78; psycopg/psycopg#888, psycopg/psycopg#1089.
- Lenguaje dominante
- Sin datos de lenguaje
- Estrellas
- 406
- Forks
- 35
- Merge medio
- 2 h 47 min
- PR fusionados (30 d)
- 5
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de microsoft/vscode-pgsql
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
microsoft/vscode-pgsql#314 · 1 comentario ·
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
microsoft/vscode-pgsql#190 · 3 comentarios ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 25/100
microsoft/vscode-pgsql#319 ·
-
Dificultad 4/5 1-2 días Aptitud para principiantes 25/100
microsoft/vscode-pgsql#318 · 1 comentario ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
microsoft/vscode-pgsql#317 · 1 comentario ·
Todos los issues de microsoft/vscode-pgsql
Issues similares
-
[BUG]: Compliance rules never see Unity Catalog views as viewsPosiblemente ocupada @wagnercsantos la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
databrickslabs/ontos#1348 ·
Los mantenedores suelen responder en 3 días
-
after-v0.1.0 bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
Los mantenedores suelen responder en 1 día
-
Add: ON Football HD feed LogoAbiertoapproved check:passed logos:add
Dificultad 1/5 Menos de una hora Aptitud para principiantes 74/100
Los mantenedores suelen responder en 2 días
-
BUG: Unhandled TypeError in updateMedicine and updateDischargeLog when data is null/undefinedAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
AOSSIE-Org/BabyNest#310 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Data/ODBC: bulk std::string extraction returns empty containers when dbEncoding is not UTF-8Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
pocoproject/poco#5659 ·
Los mantenedores suelen responder en 2 días