respect_system_proxies=true does not make Codex use the macOS system proxy (CLI & Desktop App still connect directly)
What issue are you seeing?
respect_system_proxies = true in ~/.codex/config.toml does not make Codex (both CLI and Desktop App) actually respect the system proxy. Even with the macOS system proxy set (HTTP/HTTPS proxy at 127.0.0.1:7897) and [features] respect_system_proxies = true configured, Codex still makes direct connections (not through the proxy) to domains that are not covered by the local proxy rules — e.g. Twitter/X (104.244.46.246:443) — which hang forever in SYN_SENT in restricted networks, blocking requests and causing every new session to retry ~5 times and take ~2 minutes to respond.
This is a real-world blocker: in regions where direct connections to many foreign domains are blocked, the Desktop App is nearly unusable unless we inject proxy env vars globally via launchctl setenv (which affects all GUI apps — a workaround, not a proper fix).
What steps can reproduce the bug?
- On macOS with a local proxy (e.g. Clash/Verge) listening on
127.0.0.1:7897, set the macOS system proxy to use it (scutil --proxyshows HTTP/HTTPS enabled at 7897). - Add to
~/.codex/config.toml:
``toml``
[features]
respect_system_proxies = true
- Without setting
HTTPS_PROXY/HTTP_PROXYenv vars, run the CLI:
``bash``
env -u HTTPS_PROXY -u HTTP_PROXY codex exec -c model=gpt-5.6-sol --skip-git-repo-check "Reply with exactly: OK"
- Observed: the command times out (>120s). During the hang,
lsofshows the codex process has directSYN_SENTconnections to104.244.46.246:443(Twitter/X) and similar foreign IPs that are NOT routed through the system proxy.
The same happens with the Desktop App's app-server process: direct SYN_SENT connections to non-OpenAI foreign domains, blocking session creation.
What is the expected behavior?
respect_system_proxies = true should make Codex (both CLI and Desktop App app-server) route ALL outbound HTTP/HTTPS/WebSocket requests through the macOS system proxy (or the proxy configured via network_proxy), exactly as documented for an experimental feature. Setting it should NOT require also setting HTTPS_PROXY/HTTP_PROXY env vars.
Additional information
- Codex version:
codex-cli 0.148.0-alpha.9(bundled in ChatGPT.app26.810.52044) - This appears to affect the
ReqwestDefaultoutbound proxy policy: when no proxy env vars are present, requests go direct instead of reading the macOS system proxy — even withrespect_system_proxies = true. - The Desktop App's
app-serverprocess (launched by ChatGPT.app via launchd) does not inherit shell env vars, so it can never seeHTTPS_PROXYunless injected globally — making a workingrespect_system_proxies(or equivalent) essential for GUI users in restricted networks. - Workaround used today:
launchctl setenv HTTPS_PROXY/HTTP_PROXY/ALL_PROXY http://127.0.0.1:7897(global, affects all GUI apps). A proper per-codex fix is desired. - Impacted: new session creation (retries ~5x, ~2min), subagent spawns, overall responsiveness in restricted networks.
Feature request aspect: if respect_system_proxies is intended as an experimental gate, please prioritize making it fully functional — it is the correct, scoped fix for GUI/App users behind proxies. Happy to provide more logs or test builds.
5 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
Verified:
respect_system_proxies = truedoes NOT work (tested 2026-08-18)Confirmed with concrete experiment on macOS + codex-cli 0.148.0-alpha.9:
| Step | Result |
|---|---|
| macOS system proxy set (
scutil --proxyshows HTTP/HTTPS → 127.0.0.1:7897) | ✅ ||
~/.codex/config.tomlhas[features] respect_system_proxies = true| ✅ || Run CLI with ALL proxy env removed (
env -u HTTPS_PROXY -u HTTP_PROXY -u ALL_PROXY -u NO_PROXY) | ❌ times out >120s || Connection observation | only chatgpt.com goes through Clash rules (lucky rule match); Twitter/X etc. still connect directly |
Why the experiment is conclusive:
This confirms the feature gate is implemented but not functional yet. The Desktop App path is the most impactful for users behind restricted networks, since its app-server cannot see shell env at all. Looking forward to this becoming fully functional — it is the correct scoped fix. Happy to provide more details or test a build.
Possible config-key mismatch: the feature key is singular, and unknown
[features]keys are silently ignored.On current main (@67ed4e7), the gate is
[features] respect_system_proxy(singular):features.enabled(Feature::RespectSystemProxy)keyed onrespect_system_proxy(codex-rs/core/src/config/config_loader_tests.rs:3494,config_tests.rs:1859–1917)OutboundProxyPolicyfromReqwestDefaulttoRespectSystemProxy(codex-rs/core/src/config/mod.rs:1562, 3247)[features]parses as a free-form key→bool map, sorespect_system_proxies(plural, as in the report and the verification experiment) parses without error but matches no known feature — the policy staysReqwestDefault, i.e. reqwest's own proxy selection, which with all proxy env vars removed means direct connections. That matches the observedSYN_SENThangs and the >120 s timeouts.Suggested re-test: set
[features] respect_system_proxy = true(singular) and re-run the sameenv -u HTTPS_PROXY -u HTTP_PROXY -u ALL_PROXY -u NO_PROXY codex exec …command; connections should then route via 127.0.0.1:7897. If they still don't, that would isolate a genuineRespectSystemProxy-mode gap instead.Environment: macOS 26.5.2 arm64; standalone CLI 0.147.0 + desktop-bundled 0.148; source verified on main @67ed4e7 (2026-08-19).
Thanks for the source-level diagnosis — confirmed correct, and now verified end-to-end.
Key-name fix confirmed: the feature key is singular
respect_system_proxy(notrespect_system_proxies). The plural key is silently ignored by the free-form[features]map, soOutboundProxyPolicystaysReqwestDefault(env-only → direct when env is unset). That fully explains the originalSYN_SENThangs and >120s timeouts.Verification (2026-08-19, codex 0.148.0-alpha.9 / ChatGPT.app 26.810.52044, macOS, Clash on 127.0.0.1:7897) — with
respect_system_proxy = true(singular) and ALL proxy env removed (launchctl unsetenv HTTPS_PROXY/HTTP_PROXY/ALL_PROXY):| Path | Result |
|---|---|
| CLI:
env -u HTTPS_PROXY -u HTTP_PROXY -u ALL_PROXY -u NO_PROXY codex exec "Reply OK"| ✅ exit=0, ~11s || Connection layer (lsof on codex/app-server) | ✅ 3× ESTABLISHED → 127.0.0.1:7897, 0× SYN_SENT |
| Desktop App app-server (fully quit + relaunch, no env) | ✅ new session opens immediately |
| Subagent spawn (fresh app-server process, no env) | ✅ created on first try, zero retries |
One caveat for anyone testing inside a subagent: a bare
curlchild process does NOT read the macOS system proxy (it only honors-xorHTTPS_PROXYenv), socurlto chatgpt.com timing out inside a subagent is expected — it doesn't indicate the feature is broken. The feature gates codex's own HTTP client only.I've updated the issue's premise (the original experiment used the plural key) and my local docs accordingly. Thanks again for the pointer — this is now the preferred fix (no global
launchctl setenvneeded).I can reproduce a very similar issue on an Intel Mac.
My setup:
x86_64)127.0.0.1:7897I verified that the proxy itself works. For example:
curl -s -x http://127.0.0.1:7897 \
https://www.cloudflare.com/cdn-cgi/trace
returns:
ip=
colo=NRT
loc=JP
More importantly, the OAuth token endpoint itself is reachable through exactly the same proxy:
curl -sS -x http://127.0.0.1:7897 \
https://auth.openai.com/oauth/token \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data 'grant_type=authorization_code'
This successfully reaches OpenAI and returns the expected:
"Missing 'client_id'"
I also explicitly set:
HTTP_PROXY=http://127.0.0.1:7897
HTTPS_PROXY=http://127.0.0.1:7897
ALL_PROXY=http://127.0.0.1:7897
(and the lowercase variants)
I confirmed that the actual Codex app-server process inherited all of these environment variables.
However, Codex still fails authentication with:
Failed to refresh token: error sending request for url
(https://auth.openai.com/oauth/token)
I also see similar transport errors for:
https://chatgpt.com/backend-api/plugins/featured?platform=codex
So in my case, even when the Codex app-server definitely inherits
HTTP_PROXY / HTTPS_PROXY / ALL_PROXY, its internal HTTP requests still fail,
while curl through the exact same proxy works correctly.
I have also tried reinstalling Codex, updating to 26.818.41705,
changing browsers, clearing Codex data/cache, and different network setups,
but the issue persists.
Happy to provide additional logs or run any diagnostic commands if useful.