codex - 💡(How to fix) Fix Windows Codex app: npm/network DNS fails in sandbox despite network enabled; cannot reach local proxy

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

On Windows, commands run from the Codex app cannot resolve DNS or install npm packages, even though the host PowerShell can run npm normally. The failure persists across workspace-write with sandbox_workspace_write.network_access = true and Full Access / danger-full-access mode.

The current evidence suggests a Codex Windows sandbox/network isolation issue rather than an npm registry, TLS, or package install-script problem.

Error Message

npm error code EAI_FAIL npm error syscall getaddrinfo npm error network request to https://registry.npmmirror.com/-/ping failed, reason: getaddrinfo EAI_FAIL registry.npmmirror.com npm error network request to https://registry.npmmirror.com/lodash failed, reason: getaddrinfo EAI_FAIL registry.npmmirror.com 127.0.0.1 ERROR UNKNOWN connect UNKNOWN 127.0.0.1:7897 - Local (undefined:undefined) 172.17.132.84 ERROR UNKNOWN connect UNKNOWN 172.17.132.84:7897 - Local (undefined:undefined)

Root Cause

On Windows, commands run from the Codex app cannot resolve DNS or install npm packages, even though the host PowerShell can run npm normally. The failure persists across workspace-write with sandbox_workspace_write.network_access = true and Full Access / danger-full-access mode.

The current evidence suggests a Codex Windows sandbox/network isolation issue rather than an npm registry, TLS, or package install-script problem.

Code Example

model = "gpt-5.4"
model_reasoning_effort = "high"
sandbox_mode = "workspace-write" # also tested full access / danger-full-access
approval_policy = "never"

[shell_environment_policy]
inherit = "core"

[sandbox_workspace_write]
network_access = true

[shell_environment_policy.set]
APPDATA = "C:\\Users\\user\\AppData\\Roaming"
LOCALAPPDATA = "C:\\Users\\user\\AppData\\Local"
USERPROFILE = "C:\\Users\\user"
HOME = "C:\\Users\\user"
TEMP = "C:\\Users\\user\\AppData\\Local\\Temp"
TMP = "C:\\Users\\user\\AppData\\Local\\Temp"
NPM_CONFIG_CACHE = "D:\\a311\\系统赛\\2026系统赛\\信安\\.npm-cache"
# Anthropic/OpenAI-compatible API credentials omitted/redacted

[windows]
sandbox = "elevated"

---

npm config get registry  # https://registry.npmmirror.com
npm config get proxy     # null
npm config get https-proxy # null
npm ping                 # succeeds, PONG around 176ms
node -v                  # v22.19.0
npm -v                   # 10.9.3

---

TCP    0.0.0.0:7897    0.0.0.0:0    LISTENING    <pid>
TCP    [::]:7897       [::]:0       LISTENING    <pid>

---

const dns = require('node:dns');
console.log('servers', dns.getServers());
for (const host of ['registry.npmmirror.com','registry.npmjs.org','github.com']) {
  dns.lookup(host, (err, address, family) => {
    console.log(host, err ? ('ERR ' + err.code + ' ' + err.message) : ('OK ' + address + ' IPv' + family));
  });
}
setTimeout(() => {}, 1000);

---

servers [ '223.5.5.5', '223.6.6.6', '198.18.0.2' ]
registry.npmmirror.com ERR EAI_FAIL getaddrinfo EAI_FAIL registry.npmmirror.com
registry.npmjs.org ERR EAI_FAIL getaddrinfo EAI_FAIL registry.npmjs.org
github.com ERR EAI_FAIL getaddrinfo EAI_FAIL github.com

---

npm notice PING https://registry.npmmirror.com/
npm http fetch GET https://registry.npmmirror.com/-/ping attempt 1 failed with EAI_FAIL
npm http fetch GET https://registry.npmmirror.com/-/ping attempt 2 failed with EAI_FAIL
npm http fetch GET https://registry.npmmirror.com/-/ping attempt 3 failed with EAI_FAIL
npm error code EAI_FAIL
npm error syscall getaddrinfo
npm error network request to https://registry.npmmirror.com/-/ping failed, reason: getaddrinfo EAI_FAIL registry.npmmirror.com

---

npm http fetch GET https://registry.npmmirror.com/npm attempt 1 failed with EAI_FAIL
npm http fetch GET https://registry.npmmirror.com/lodash attempt 1 failed with EAI_FAIL
...
npm error network request to https://registry.npmmirror.com/lodash failed, reason: getaddrinfo EAI_FAIL registry.npmmirror.com

---

127.0.0.1 ERROR UNKNOWN connect UNKNOWN 127.0.0.1:7897 - Local (undefined:undefined)
172.17.132.84 ERROR UNKNOWN connect UNKNOWN 172.17.132.84:7897 - Local (undefined:undefined)

---

$env:HTTP_PROXY='http://127.0.0.1:7897'
$env:HTTPS_PROXY='http://127.0.0.1:7897'
npm ping --verbose

---

reason: connect UNKNOWN 127.0.0.1:7897 - Local (undefined:undefined)
RAW_BUFFERClick to expand / collapse

Summary

On Windows, commands run from the Codex app cannot resolve DNS or install npm packages, even though the host PowerShell can run npm normally. The failure persists across workspace-write with sandbox_workspace_write.network_access = true and Full Access / danger-full-access mode.

The current evidence suggests a Codex Windows sandbox/network isolation issue rather than an npm registry, TLS, or package install-script problem.

Environment

  • OS: Windows 10.0.26200
  • Codex app package observed in PATH: OpenAI.Codex_26.415.4716.0_x64__2p2nqsd0c76g0
  • Shell: PowerShell
  • Node: v22.19.0
  • npm: 10.9.3
  • npm registry: https://registry.npmmirror.com
  • npm proxy: null
  • npm https-proxy: null
  • Project trusted in config
  • Tested sandbox modes:
    • workspace-write with [sandbox_workspace_write] network_access = true
    • Full access / danger-full-access
  • Approval policy: never

Redacted config shape

model = "gpt-5.4"
model_reasoning_effort = "high"
sandbox_mode = "workspace-write" # also tested full access / danger-full-access
approval_policy = "never"

[shell_environment_policy]
inherit = "core"

[sandbox_workspace_write]
network_access = true

[shell_environment_policy.set]
APPDATA = "C:\\Users\\user\\AppData\\Roaming"
LOCALAPPDATA = "C:\\Users\\user\\AppData\\Local"
USERPROFILE = "C:\\Users\\user"
HOME = "C:\\Users\\user"
TEMP = "C:\\Users\\user\\AppData\\Local\\Temp"
TMP = "C:\\Users\\user\\AppData\\Local\\Temp"
NPM_CONFIG_CACHE = "D:\\a311\\系统赛\\2026系统赛\\信安\\.npm-cache"
# Anthropic/OpenAI-compatible API credentials omitted/redacted

[windows]
sandbox = "elevated"

Expected behavior

From a Codex shell with network access enabled, npm should be able to resolve the configured registry and install a simple package such as lodash, or at least connect to the host's configured local proxy when explicitly configured.

Actual behavior

Host PowerShell works

The user's normal PowerShell reports:

npm config get registry  # https://registry.npmmirror.com
npm config get proxy     # null
npm config get https-proxy # null
npm ping                 # succeeds, PONG around 176ms
node -v                  # v22.19.0
npm -v                   # 10.9.3

The host also has a local proxy listening on port 7897:

TCP    0.0.0.0:7897    0.0.0.0:0    LISTENING    <pid>
TCP    [::]:7897       [::]:0       LISTENING    <pid>

Codex shell fails DNS resolution

In the Codex shell:

const dns = require('node:dns');
console.log('servers', dns.getServers());
for (const host of ['registry.npmmirror.com','registry.npmjs.org','github.com']) {
  dns.lookup(host, (err, address, family) => {
    console.log(host, err ? ('ERR ' + err.code + ' ' + err.message) : ('OK ' + address + ' IPv' + family));
  });
}
setTimeout(() => {}, 1000);

Output:

servers [ '223.5.5.5', '223.6.6.6', '198.18.0.2' ]
registry.npmmirror.com ERR EAI_FAIL getaddrinfo EAI_FAIL registry.npmmirror.com
registry.npmjs.org ERR EAI_FAIL getaddrinfo EAI_FAIL registry.npmjs.org
github.com ERR EAI_FAIL getaddrinfo EAI_FAIL github.com

npm ping --verbose fails with:

npm notice PING https://registry.npmmirror.com/
npm http fetch GET https://registry.npmmirror.com/-/ping attempt 1 failed with EAI_FAIL
npm http fetch GET https://registry.npmmirror.com/-/ping attempt 2 failed with EAI_FAIL
npm http fetch GET https://registry.npmmirror.com/-/ping attempt 3 failed with EAI_FAIL
npm error code EAI_FAIL
npm error syscall getaddrinfo
npm error network request to https://registry.npmmirror.com/-/ping failed, reason: getaddrinfo EAI_FAIL registry.npmmirror.com

npm install lodash --verbose --no-audit --no-fund fails before package metadata is fetched:

npm http fetch GET https://registry.npmmirror.com/npm attempt 1 failed with EAI_FAIL
npm http fetch GET https://registry.npmmirror.com/lodash attempt 1 failed with EAI_FAIL
...
npm error network request to https://registry.npmmirror.com/lodash failed, reason: getaddrinfo EAI_FAIL registry.npmmirror.com

npm install esbuild --verbose --no-audit --no-fund fails the same way, before any secondary binary download is reached.

Local proxy is not reachable from Codex shell

The host proxy is listening on 7897, but the Codex shell cannot connect to it:

127.0.0.1 ERROR UNKNOWN connect UNKNOWN 127.0.0.1:7897 - Local (undefined:undefined)
172.17.132.84 ERROR UNKNOWN connect UNKNOWN 172.17.132.84:7897 - Local (undefined:undefined)

When HTTP_PROXY and HTTPS_PROXY are set manually inside the Codex shell:

$env:HTTP_PROXY='http://127.0.0.1:7897'
$env:HTTPS_PROXY='http://127.0.0.1:7897'
npm ping --verbose

The failure changes from DNS EAI_FAIL to proxy connection failure:

reason: connect UNKNOWN 127.0.0.1:7897 - Local (undefined:undefined)

This suggests npm obeys the explicit proxy env vars, but Codex cannot reach the host-local proxy endpoint.

Additional observations

  • In workspace-write, the shell cwd appears under C:\Users\CodexSandboxOnline\.codex\.sandbox\cwd\....
  • In Full Access / danger-full-access, the environment variables from shell_environment_policy.set are correctly injected:
    • APPDATA=C:\Users\user\AppData\Roaming
    • LOCALAPPDATA=C:\Users\user\AppData\Local
    • NPM_CONFIG_CACHE=...\.npm-cache
  • Full Access fixes npm cache/log path issues, but DNS still fails with EAI_FAIL.
  • With Clash TUN enabled, route/DNS state changes are visible in Codex (198.18.0.2 appears), but DNS resolution still fails.
  • Toggling TUN on/off, enabling global proxy mode, changing TUN MTU to 1500, switching between workspace-write and Full Access, and setting network_access = true did not restore npm networking.

Why this looks like a Codex Windows networking issue

The same Node/npm versions and npm registry settings work in the user's normal PowerShell. In the Codex shell, DNS fails for multiple unrelated domains and direct connections to the host's local proxy also fail. The failure happens before npm can reach package metadata or any install-script secondary download.

Request

Please investigate Codex app on Windows sandbox networking / DNS / host-local proxy access. Specifically:

  1. Why does DNS resolution return EAI_FAIL in Codex shells when the host PowerShell can resolve and npm ping succeeds?
  2. Why can the host connect to 127.0.0.1:7897, while the Codex shell cannot connect to 127.0.0.1:7897 or the host LAN IP 172.17.132.84:7897?
  3. Is there a supported config option to allow Codex Windows sandbox sessions to use host system proxy / local loopback proxy?
  4. Is [sandbox_workspace_write] network_access = true expected to work in the Windows app, and does it cover DNS plus host-local proxy access?

Sensitive tokens and API credentials have been omitted from this report.

extent analysis

TL;DR

The issue is likely due to Codex Windows sandbox networking limitations, and a potential workaround is to configure the host system's proxy settings to allow the Codex shell to access the npm registry.

Guidance

  • Investigate the Codex app's sandbox networking configuration to determine if there are any restrictions on DNS resolution or host-local proxy access.
  • Try setting the HTTP_PROXY and HTTPS_PROXY environment variables in the Codex shell to point to the host system's proxy endpoint, and verify if this resolves the DNS resolution issue.
  • Check the Codex app's documentation to see if there are any supported config options to allow the Windows sandbox sessions to use the host system's proxy or local loopback proxy.
  • Verify that the [sandbox_workspace_write] network_access = true configuration option is correctly enabled and covers both DNS and host-local proxy access.

Example

No code snippet is provided as the issue is related to configuration and networking.

Notes

The issue seems to be specific to the Codex Windows app and its sandbox networking implementation. The fact that the host PowerShell can resolve DNS and access the npm registry suggests that the issue is not related to the npm registry or the host system's network configuration.

Recommendation

Apply a workaround by configuring the host system's proxy settings to allow the Codex shell to access the npm registry, as this may help resolve the DNS resolution issue.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

From a Codex shell with network access enabled, npm should be able to resolve the configured registry and install a simple package such as lodash, or at least connect to the host's configured local proxy when explicitly configured.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

codex - 💡(How to fix) Fix Windows Codex app: npm/network DNS fails in sandbox despite network enabled; cannot reach local proxy