Can't connect to containerized localhost Postgres on a domain joined Mac
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 48/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 技術堆疊
- macos, postgresql
- 領域
- database
研究方向
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.
由索引模型根據 Issue 內容生成。
描述
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.
- 主要語言
- 沒有語言資料
- 星號
- 406
- 分支
- 35
- 平均合併
- 2 小時 47 分鐘
- 30 天內合併 PR
- 5
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
microsoft/vscode-pgsql 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 62/100
microsoft/vscode-pgsql#314 · 1 則留言 ·
-
enhancement
難度 2/5 1-3 小時 新手友好度 68/100
microsoft/vscode-pgsql#190 · 3 則留言 ·
-
難度 4/5 3-5 天 新手友好度 25/100
microsoft/vscode-pgsql#319 ·
-
難度 4/5 1-2 天 新手友好度 25/100
microsoft/vscode-pgsql#318 · 1 則留言 ·
-
難度 4/5 3-5 天 新手友好度 48/100
microsoft/vscode-pgsql#317 · 1 則留言 ·
查看 microsoft/vscode-pgsql 的全部 Issue
相似的 Issue
-
[BUG]: Compliance rules never see Unity Catalog views as views可能已有人在做 @wagnercsantos 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
databrickslabs/ontos#1348 ·
維護者通常 3 天內回覆
-
after-v0.1.0 bug
難度 2/5 1-3 小時 新手友好度 74/100
維護者通常 1 天內回覆
-
approved check:passed logos:add
難度 1/5 1 小時以內 新手友好度 74/100
維護者通常 2 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
AOSSIE-Org/BabyNest#310 · 1 則留言 ·
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 78/100
pocoproject/poco#5659 ·
維護者通常 2 天內回覆