Skip to content

Windows: Codex-spawned PowerShell crashes on startup and curl DNS lookup fails while normal terminal works #14221

Open

Description

@saichaithanya0705

Summary

Inside Codex on Windows, standard network commands fail even though the same commands work in my normal terminal.

Repro

Run inside Codex:

  • Resolve-DnsName chatgpt.com
  • curl.exe -I https://chatgpt.com

Expected

Both commands should work the same way they do in my normal Windows terminal.

Actual

PowerShell fails during startup before Resolve-DnsName can run.
Observed errors included:

  • System.TypeInitializationException
  • InitialSessionState
  • GetSaferPolicy
  • AppLocker
  • System.ComponentModel.Win32Exception (126): The specified module could not be found

curl.exe failed with:

  • curl: (2) getaddrinfo() thread failed to start

A separate resolver test in the Codex-run environment also failed with getaddrinfo failed, while the same host resolves correctly in my normal terminal.

Important context

This appears to be specific to the Codex child-process/runtime environment, not general DNS failure on the machine.
My normal terminal can resolve and access the host correctly.

Environment

  • OS: Windows 11 / Windows build 10.0.26200.7922
  • Repo/runtime context: Codex terminal environment on Windows
  • powershell.exe exists
  • pwsh.exe exists
  • failure happens only from the Codex-run process environment

Notes

This reproduced again after a clean reinstall initially appeared to fix it, which suggests the problem is intermittent or environment-triggered rather than a one-time corrupted install.

Activity

  1. added
    bug
    CLI
    windows-os
    tool-calls
    on Mar 10, 2026
  2. added
    app
    and removed
    CLI
    on Mar 10, 2026
  3. removed
    tool-calls
    on Mar 30, 2026
  4. rza255 commented on Sep 28, 2026

    @rza255

    Additional reproducible datapoint for the PowerShell-startup side of this issue:

    On native Windows / codex-cli 0.153.4, the exact bundled pwsh works normally outside Codex sandboxing. Inside an elevated read-only Codex sandbox, native cmd.exe and where.exe also work, but minimal pwsh startup fails before the requested command with:

    InitialSessionState
     -> GetSaferPolicy
     -> Win32Exception (126)
    

    The sandbox environment was missing SystemRoot.

    Adding only:

    SystemRoot=C:\Windows
    

    to the child environment fixed minimal PowerShell startup.

    I then repeated a hermetic codex exec test with user config/rules ignored, read-only sandboxing, windows.sandbox="elevated", inherit="none", and only SystemRoot restored. PowerShell started and a single read-only scratch-file command succeeded.

    No Full Access / unsandboxed fallback was required.

    This does not address the DNS half of this issue, but it appears to be a concrete minimal workaround for the PowerShell InitialSessionState/GetSaferPolicy/126 failure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    appbugwindows-os

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions