Windows Codex app: npm/network DNS fails in sandbox despite network enabled; cannot reach local proxy
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-writewith[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 underC:\Users\CodexSandboxOnline\.codex\.sandbox\cwd\.... - In Full Access /
danger-full-access, the environment variables fromshell_environment_policy.setare correctly injected: APPDATA=C:\Users\user\AppData\RoamingLOCALAPPDATA=C:\Users\user\AppData\LocalNPM_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.2appears), 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 = truedid 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:
- Why does DNS resolution return
EAI_FAILin Codex shells when the host PowerShell can resolve and npm ping succeeds? - Why can the host connect to
127.0.0.1:7897, while the Codex shell cannot connect to127.0.0.1:7897or the host LAN IP172.17.132.84:7897? - Is there a supported config option to allow Codex Windows sandbox sessions to use host system proxy / local loopback proxy?
- Is
[sandbox_workspace_write] network_access = trueexpected 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.
6 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
I've been encountering this issue since one or two months ago. can't endure it when my workloads get heavier. hope it will solve quickly.
I have a practical Windows workaround that is now working reliably for me. Sharing it here in case it helps others until the Codex App Windows sandbox networking behavior is fixed.
Environment / symptom
26.422.2339.0npm pingsucceeds).In one affected WSL2/Linux Codex session, the spawned command was clearly running under:
This was true even though my
~/.codex/config.tomlcontained settings such as:So the important point is not only WSL2. The broader issue is that the Codex Windows app sandbox can prevent network access for commands that would otherwise work in the normal Windows terminal environment.
What failed inside the sandbox
Running npm directly inside the Codex sandbox failed before package installation logic or postinstall scripts were reached:
Manually injecting my local proxy inside the sandbox also failed in that session:
So this does not look like an npm package issue, an esbuild/sharp binary-download issue, or a TLS certificate issue. The failure happens at the registry/DNS/proxy-access layer inside the Codex sandbox.
Windows-wide workaround that works
For network-dependent commands, run only that command outside the Codex sandbox instead of retrying inside the restricted sandbox.
For Windows-native PowerShell/CMD commands, run the command in the host Windows environment, where normal Windows proxy/network settings apply. Example:
For WSL2/Linux commands, run the command outside the Codex sandbox and explicitly inject the Windows local proxy if needed:
The proxy port may differ for other users. In my case the Windows local proxy was listening on
127.0.0.1:7897.With this approach, all of the following succeeded after being run outside the Codex sandbox:
Recommended operational pattern
The safest pattern for now is:
npm install,pip install,git fetch/pull/push, dependency downloads, or external API calls.This is a Windows Codex sandbox networking workaround, not a WSL2-only workaround. WSL2 was just the environment used in my latest reproduction; the same operational pattern applies to native PowerShell/CMD tasks on Windows as well.
@re-gion thanks, wow... will try it!
Thank you for your workaround tips!
As I looked over my logs in codex, I found executing commands out of sandboxes was what my Codex always does.
Yeah, nothing new was found for me, so still hope this issue will be fixed asap.
Evidence on my end if a maintainer finds it useful:
```Host PowerShell:
npm ping -> PONG
Invoke-WebRequest https://registry.npmjs.org/typescript -> 200
nslookup registry.npmjs.org -> resolves
Codex shell:
npm ping -> timeout
node dns.lookup("registry.npmjs.org") -> EAI_FAIL
cmd /c nslookup registry.npmjs.org -> no response from same DNS server
npm config proxy/https-proxy -> null
sandbox_mode = danger-full-access
network access enabled