Skip to content

can't start in windows #48016

Closed
Closed

Description

@panchen451161722

What version of Codex CLI is running?

codex-cli 0.157.0

What subscription do you have?

no

Which model were you using?

No response

What platform is your computer?

No response

What terminal emulator and version are you using (if applicable)?

No response

Codex doctor report

codex
Error: host Job Object prevents daemon detachment; start from a host that allows breakaway
To work without the background server, rerun the same command with --no-daemon (including resume or fork and its arguments).

What issue are you seeing?

Image

What steps can reproduce the bug?

just start

What is the expected behavior?

No response

Additional information

No response

Activity

  1. added
    CLIIssues related to the Codex CLI
    windows-osIssues related to Codex on Windows systems
    app-serverIssues involving app server protocol or interfaces
    on Sep 25, 2026
  2. 24online24 commented on Sep 25, 2026

    @24online24

    I have encountered the same issue after the upgrade to 0.157.0.

    PS ~\code> codex
    Error: host Job Object prevents daemon detachment; start from a host that allows breakaway
    To work without the background server, rerun the same command with --no-daemon (including resume or fork and its arguments).
    PS ~\code> codex --version
    codex-cli 0.157.0
    PS ~\code>
    
  3. vidi42 commented on Sep 25, 2026

    @vidi42

    Just upgraded to 0.157.0 and got the same

    PS path\to\project> codex
    Error: host Job Object prevents daemon detachment; start from a host that allows breakaway
    To work without the background server, rerun the same command with --no-daemon (including resume or fork and its arguments).
    
  4. sjasct commented on Sep 25, 2026

    @sjasct

    Getting the same here, codex 0.157.0 is installed under npm 11.19.0, Win 11 25H2 26200.8246

    Error: host Job Object prevents daemon detachment; start from a host that allows breakaway
    To work without the background server, rerun the same command with --no-daemon (including resume or fork and its arguments).
    
  5. model-bender commented on Sep 25, 2026

    @model-bender

    Same here after updating to 0.157.0: plain codex exits with this error. Adding data that answers the survival question asked in #44503.

    Environment

    • Windows 11 Home, build 26200, ARM64 (npm @openai/codex 0.157.0, aarch64-pc-windows-msvc binary)
    • Windows Terminal 1.24 with Git Bash; the probes below also ran from PowerShell started outside Git Bash
    • Modern Standby supported (powercfg /a: "Standby (S0 Low Power Idle) Network Connected"), dam service running

    Membership probe (first script below)

    • The caller's immediate job has LimitFlags=0x1800 (BREAKAWAY_OK and SILENT_BREAKAWAY_OK, no KILL_ON_JOB_CLOSE) and holds about 145 active processes. explorer.exe is in a job too, so the job is session-wide rather than added by the terminal.
    • A child created with CREATE_SUSPENDED | DETACHED_PROCESS | CREATE_BREAKAWAY_FROM_JOB is created fine, but IsProcessInJob(child, NULL) is TRUE. Same result with and without Git Bash in the chain.

    Survival probe (second script below)
    The child is spawned with the daemon's own flags from pid_start.rs (DETACHED_PROCESS | CREATE_BREAKAWAY_FROM_JOB) and checked from a separate observer process:

    exit  launcher exited=True (code 0); child 40636 at spawn: in-job; alive 5s after launcher gone: True; now: in-job
    wait  launcher exited=True (code -1073741510); child 8788 at spawn: in-job; alive 5s after launcher gone: True; now: in-job
    
    • exit: the launcher exits normally. The child keeps running.
    • wait: the launcher's console window gets WM_CLOSE (what the X button sends), and the launcher dies with STATUS_CONTROL_C_EXIT. The child keeps running.

    So on this machine the residual job does not stop a detached child from outliving its launcher or its console. Not tested: behaviour across Modern Standby (DAM may throttle processes in its job), logoff, or closing a Windows Terminal tab (the probe used a hidden conhost window).

    Suggestion: now that 0.157.0 starts the daemon by default, a failed detachment check makes Codex unusable instead of only disabling codex agents. Falling back to in-process mode with a warning (what --no-daemon does) would avoid that, however the job check itself ends up.

    Workaround in ~/.codex/config.toml:

    [features]
    daemon_auto_start = false
    Membership probe (PowerShell)
    Add-Type -TypeDefinition @"
    using System;
    using System.Runtime.InteropServices;
    public static class B {
      [StructLayout(LayoutKind.Sequential)] public struct SI { public int cb; public IntPtr r, d, t; public int x, y, xs, ys, xc, yc, fa, fl; public short sw, cb2; public IntPtr r2, i, o, e; }
      [StructLayout(LayoutKind.Sequential)] public struct PI { public IntPtr hP, hT; public int pid, tid; }
      [StructLayout(LayoutKind.Sequential)] public struct BASIC { public long a, b; public uint LimitFlags; public UIntPtr c, d; public uint e; public UIntPtr f; public uint g, h; }
      [StructLayout(LayoutKind.Sequential)] public struct IOC { public ulong a, b, c, d, e, f; }
      [StructLayout(LayoutKind.Sequential)] public struct EXT { public BASIC Basic; public IOC Io; public UIntPtr p, j, pp, jp; }
      [StructLayout(LayoutKind.Sequential)] public struct ACCT { public long a, b, c, d; public uint TotalPageFaultCount, TotalProcesses, ActiveProcesses, TotalTerminatedProcesses; }
      [DllImport("kernel32.dll", SetLastError=true, CharSet=CharSet.Unicode)] public static extern bool CreateProcessW(string app, System.Text.StringBuilder cmd, IntPtr pa, IntPtr ta, bool inh, uint flags, IntPtr env, string cwd, ref SI si, out PI pi);
      [DllImport("kernel32.dll", SetLastError=true)] public static extern bool IsProcessInJob(IntPtr p, IntPtr j, out bool r);
      [DllImport("kernel32.dll", SetLastError=true)] public static extern bool QueryInformationJobObject(IntPtr j, int cls, out EXT info, int len, IntPtr ret);
      [DllImport("kernel32.dll", SetLastError=true)] public static extern bool QueryInformationJobObject(IntPtr j, int cls, out ACCT info, int len, IntPtr ret);
      [DllImport("kernel32.dll")] public static extern bool TerminateProcess(IntPtr h, uint c);
      [DllImport("kernel32.dll")] public static extern bool CloseHandle(IntPtr h);
      public static string Run() {
        string o = "";
        EXT e; if (QueryInformationJobObject(IntPtr.Zero, 9, out e, Marshal.SizeOf(typeof(EXT)), IntPtr.Zero)) {
          uint f = e.Basic.LimitFlags;
          o += string.Format("own job LimitFlags=0x{0:X} BREAKAWAY_OK={1} SILENT_BREAKAWAY_OK={2} KILL_ON_CLOSE={3}\n", f, (f & 0x800) != 0, (f & 0x1000) != 0, (f & 0x2000) != 0);
        } else o += "own job query failed err=" + Marshal.GetLastWin32Error() + "\n";
        ACCT a; if (QueryInformationJobObject(IntPtr.Zero, 1, out a, Marshal.SizeOf(typeof(ACCT)), IntPtr.Zero))
          o += string.Format("own job ActiveProcesses={0} TotalProcesses={1}\n", a.ActiveProcesses, a.TotalProcesses);
        SI si = new SI(); si.cb = Marshal.SizeOf(typeof(SI)); PI pi;
        // same flags as codex ensure_detached_launch: CREATE_SUSPENDED | DETACHED_PROCESS | CREATE_BREAKAWAY_FROM_JOB
        uint flags = 0x4 | 0x8 | 0x01000000;
        if (!CreateProcessW(@"C:\Windows\System32\cmd.exe", new System.Text.StringBuilder("cmd.exe /c exit"), IntPtr.Zero, IntPtr.Zero, false, flags, IntPtr.Zero, null, ref si, out pi))
          return o + "breakaway CreateProcess FAILED err=" + Marshal.GetLastWin32Error();
        bool inJob; IsProcessInJob(pi.hP, IntPtr.Zero, out inJob);
        TerminateProcess(pi.hP, 0); CloseHandle(pi.hT); CloseHandle(pi.hP);
        return o + "breakaway child in job after CREATE_BREAKAWAY_FROM_JOB: " + inJob;
      }
    }
    "@
    [B]::Run()
    Survival probe (PowerShell)
    # Survival probe for openai/codex#44503. Launcher mode spawns a long-lived child with the
    # daemon's own flags (DETACHED_PROCESS | CREATE_BREAKAWAY_FROM_JOB), records it, then
    # either exits or waits for its console window to be closed. Observer mode drives both.
    param([string]$Mode = 'observe', [string]$Out = "$env:TEMP\codex-lifecycle")
    Add-Type -TypeDefinition @"
    using System;
    using System.Runtime.InteropServices;
    public static class L {
      [StructLayout(LayoutKind.Sequential)] public struct SI { public int cb; public IntPtr r, d, t; public int x, y, xs, ys, xc, yc, fa, fl; public short sw, cb2; public IntPtr r2, i, o, e; }
      [StructLayout(LayoutKind.Sequential)] public struct PI { public IntPtr hP, hT; public int pid, tid; }
      [DllImport("kernel32.dll", SetLastError=true, CharSet=CharSet.Unicode)] public static extern bool CreateProcessW(string app, System.Text.StringBuilder cmd, IntPtr pa, IntPtr ta, bool inh, uint flags, IntPtr env, string cwd, ref SI si, out PI pi);
      [DllImport("kernel32.dll", SetLastError=true)] public static extern IntPtr OpenProcess(uint a, bool i, int pid);
      [DllImport("kernel32.dll", SetLastError=true)] public static extern bool IsProcessInJob(IntPtr p, IntPtr j, out bool r);
      [DllImport("kernel32.dll")] public static extern bool CloseHandle(IntPtr h);
      [DllImport("kernel32.dll")] public static extern IntPtr GetConsoleWindow();
      [DllImport("user32.dll")] public static extern bool PostMessageW(IntPtr h, uint m, IntPtr w, IntPtr l);
      public static int Spawn() {
        SI si = new SI(); si.cb = Marshal.SizeOf(typeof(SI)); PI pi;
        // DETACHED_PROCESS | CREATE_BREAKAWAY_FROM_JOB, as in app-server-daemon/src/backend/pid_start.rs
        if (!CreateProcessW(@"C:\Windows\System32\PING.EXE", new System.Text.StringBuilder("PING.EXE -n 120 127.0.0.1"), IntPtr.Zero, IntPtr.Zero, false, 0x8 | 0x01000000, IntPtr.Zero, null, ref si, out pi))
          throw new Exception("CreateProcess failed " + Marshal.GetLastWin32Error());
        CloseHandle(pi.hT); CloseHandle(pi.hP); return pi.pid;
      }
      public static string InJob(int pid) {
        IntPtr h = OpenProcess(0x1000, false, pid); if (h == IntPtr.Zero) return "gone";
        bool r; IsProcessInJob(h, IntPtr.Zero, out r); CloseHandle(h); return r ? "in-job" : "no-job";
      }
    }
    "@
    if ($Mode -ne 'observe') {
      $child = [L]::Spawn()
      "$child $([L]::InJob($child)) $([L]::GetConsoleWindow().ToInt64())" | Set-Content "$Out-$Mode.txt"
      if ($Mode -eq 'wait') { while ($true) { Start-Sleep 1 } }
      exit 0
    }
    $self = $MyInvocation.MyCommand.Path
    foreach ($m in 'exit', 'wait') {
      Remove-Item "$Out-$m.txt" -ErrorAction SilentlyContinue
      $launcher = Start-Process powershell.exe -WindowStyle Hidden -PassThru `
        -ArgumentList '-NoProfile', '-ExecutionPolicy', 'Bypass', '-File', "`"$self`"", '-Mode', $m
      while (-not (Test-Path "$Out-$m.txt")) { Start-Sleep -Milliseconds 200 }
      Start-Sleep -Milliseconds 500
      $childPid, $jobAtSpawn, $hwnd = (Get-Content "$Out-$m.txt").Split(' ')
      if ($m -eq 'wait') {
        # Close the launcher's console window the way the X button does (WM_CLOSE = 0x10).
        [void][L]::PostMessageW([IntPtr][long]$hwnd, 0x10, [IntPtr]::Zero, [IntPtr]::Zero)
      }
      $launcher.WaitForExit(15000) | Out-Null
      Start-Sleep -Seconds 5
      $alive = [bool](Get-Process -Id $childPid -ErrorAction SilentlyContinue)
      "{0,-5} launcher exited={1} (code {2}); child {3} at spawn: {4}; alive 5s after launcher gone: {5}; now: {6}" -f `
        $m, $launcher.HasExited, $launcher.ExitCode, $childPid, $jobAtSpawn, $alive, [L]::InJob([int]$childPid)
      Stop-Process -Id $childPid -Force -ErrorAction SilentlyContinue
    }
  6. moonrailgun commented on Sep 25, 2026

    @moonrailgun

    same here and

    [features]
    daemon_auto_start = false
    

    work for me

  7. gitPhate commented on Sep 25, 2026

    @gitPhate

    same here and

    [features]
    daemon_auto_start = false
    

    work for me

    I tried this and codex opens but at the first prompt I get

    - The first shell launch failed before running the inspection commands, so I’m retrying with a simpler repository read.
    - I couldn’t inspect or update _sut: the shell failed to start on each attempt, so I couldn’t read the test or service constructor. No files were changed. Please retry once the workspace shell is available
    
  8. nikolaidk commented on Sep 25, 2026

    @nikolaidk

    I have similar issue on MAC

    Image
  9. Transient-Onlooker commented on Sep 25, 2026

    @Transient-Onlooker
    Image had the same issue in Windows 11
  10. tleneel commented on Sep 25, 2026

    @tleneel

    I just updated the codex as it requested an updated. And upon return I have the same error :/

    Here is the fix : npx --yes @openai/codex@0.156.0 → DO NOT accept to upgrade to 0.157, press "3 - skip this version" :)

  11. Bolt81 commented on Sep 25, 2026

    @Bolt81

    I can confirm the same issue after upgrading to Codex CLI 0.157.0 on Windows.

    Normal startup fails:

    codex
    → fails during startup
    

    Starting with the daemon disabled works normally:

    codex --no-daemon
    → starts successfully
    

    So, at least in my environment, the failure appears isolated to the new background-server/daemon startup path introduced/enabled in 0.157.0. The interactive Codex session itself works when the daemon is bypassed.

    Environment:

    • OS: Windows
    • Codex CLI: 0.157.0
    • Workaround: codex --no-daemon
  12. thanh-abaii commented on Sep 25, 2026

    @thanh-abaii

    I'm experiencing exactly the same issue with Codex CLI 0.157.0 on Windows, using PowerShell.

    Steps to reproduce:

    Open PowerShell.

    Run codex.

    Actual behavior:

    Error: host Job Object prevents daemon detachment; start from a host that allows breakaway
    To work without the background server, rerun the same command with --no-daemon (including resume or fork and its arguments).

    Expected behavior:
    Codex should start normally, as before, or automatically fall back to non-daemon mode if daemon detachment is unavailable.

    This issue appeared after upgrading to 0.157.0.

  13. 10 remaining items

  14. Utahleo commented on Sep 25, 2026

    @Utahleo

    I can reproduce this on Windows x64 with Codex CLI 0.157.0, and I did some additional Windows Job Object diagnostics that may help narrow the regression.

    Environment

    • Hardware: Microsoft Surface Laptop 3
    • OS: Windows 11 Pro x64
    • Version/build: 10.0.26200 / build 26200.9457
    • Power model: Modern Standby — Standby (S0 Low Power Idle), Network Connected
    • HypervisorPresent: True
    • Virtualization-based security: Running
    • Codex installation: official standalone Windows PowerShell installer

    Reproduction on 0.157.0

    > codex --version
    codex-cli 0.157.0
    
    > codex
    Error: host Job Object prevents daemon detachment; start from a host that allows breakaway
    To work without the background server, rerun the same command with --no-daemon (including resume or fork and its arguments).
    
    > codex app-server daemon start
    Error: host Job Object prevents daemon detachment; start from a host that allows breakaway
    

    The same failure occurs from both PowerShell 7.6.6 and plain cmd.exe.

    codex --no-daemon works.

    I also performed a clean reinstall of 0.157.0 using the standalone installer; the behavior was unchanged.

    Windows Job Object diagnostics

    Using IsProcessInJob confirms the shell is in a Job Object:

    ApiCallSucceeded : True
    ProcessIsInJob   : True
    

    However, querying JobObjectExtendedLimitInformation reports:

    LimitFlagsHex      : 0x00000800
    BreakawayOK        : True
    SilentBreakawayOK  : False
    KillOnJobClose     : False
    ActiveProcessLimit : 0
    

    So the host Job Object has JOB_OBJECT_LIMIT_BREAKAWAY_OK set. Despite that, 0.157.0 reports that the host prevents daemon detachment.

    Regression test

    I downgraded the same machine to:

    codex-cli 0.155.0
    

    Plain codex then starts normally without --no-daemon.

    No Windows/VBS/Hyper-V/Modern Standby configuration was changed between the 0.157.0 failure and the successful 0.155.0 test.

    This looks like a regression between 0.155.0 and 0.157.0 in the Windows daemon detachment/Job Object handling. In particular, it may be worth checking whether the newer daemon startup path is treating presence in a Job Object as non-breakaway even when JOB_OBJECT_LIMIT_BREAKAWAY_OK is present.

  15. jzhu230 commented on Sep 26, 2026

    @jzhu230

    I have encountered the same issue, and I solved it by telling codex (using the GUI) to downgrade to 0.156.1

  16. borzaka commented on Sep 26, 2026

    @borzaka

    Looks like it's fixed in 0.157.1, the CLI now starts.

  17. gitPhate commented on Sep 26, 2026

    @gitPhate

    Weird enough I see terminals spawning whatever command codex is running, does that happen to anyone?

  18. abarefoot commented on Sep 26, 2026

    @abarefoot

    Weird enough I see terminals spawning whatever command codex is running, does that happen to anyone?

    I experience this too, running 0.157.1 in pwsh 7.6.6 on Windows 11. It makes it very hard to use codex CLI. codex --no-daemon doesn't have this behavior though.

  19. kevin-alt-acct commented on Sep 26, 2026

    @kevin-alt-acct
  20. etraut-openai commented on Sep 26, 2026

    @etraut-openai
    Contributor

    We published 0.157.1 as a hot-fix release to address this issue. If you're still seeing this problem after updating, let us know.

  21. tleneel commented on Sep 26, 2026

    @tleneel

    loading, but with issues. It spam by itself text like :

    [M#x1[M#u1[M#q1[M#m1[M#l1[M#i1[M#h1[M#d1[M#c1[M#1[M#_1[M#]1[M#\1[M#X1[M#U1[M#S2[M#R2[M#Q2[M#P2[M#N2[M#M2[M#L2[M#K2[M#J2[M#J3[M#O2[M#O1[M#N1[M#N0[M#N/[M#O/[M#P/ [M#Q/[M#R/[M#Q/[M#P/[M#M.[M#J.[M#G.[M#E.[M#D.[M#C.[M#B.[M#A.[M#?.[M#>.[M#;.[M#9.[M#8.[M#7.[M#6.[M#5.[M#4.[M#3.[M#2.[M#1.[M#0.[M#/.[M#..[M#-.[M#,.[M#+.[M#*.[M#*/[M#+/ [M#,0[M#-0[M#.0[M#/0[M#//[M#0/[M#1/[M#1.[M#0.[M#/.[M#..[M 3,[M#3,[M#3,[M#3-[M 3-[M@5-[M@7-[M@9-[M@:-[M@<,[M@@,[M@C,[M@F,[M@I,[M@L,[M@M,[M@S,[M@V,[M@X,[M@[,[M@\,[M@],[M@_,[M@,
    [M@a,[M@c,[M@d,[M@f,[M@g-[M@h-[M@j-[M@k-[M@l-[M@l.[M@m.[M@n/[M@o/[M@p/[M@q/[M@r/[M@s/[M@t/[M@t0[M@u0[M@v0[M@w0[M@x0[M@y0[M@z0[M@{0[M@|0[M@}0[M#}0[M#|
    0[M#{0[M#z0[M#y0[M#v0[M#t0[M#s0[M#p0[M#o0[M#n0[M#m0[M#m/[M m/[M#Z,[M#X,[M#V,[M#U,[M#T,[M#S,[M#R,[M#Q,[M#P,[M#O,[M#N,[M#M,[M#L,[M#K,[M#J,[M#I,[M#H,[M#G,[M#F,
    [M#F+[M#E+[M#D+[M#C+[M#B+[M#A+[M#@+[M#?+[M#>+[M#=+[M#<+[M#;+[M#:+[M#9+[M#8+[M#8,[M#6,[M#4,[M#3,[M#2,[M#1,[M#0,[M#0+[M#/+[M#.+[M#-+[M#,+[M#.+[M#/+[M#0+[M#1+[M#1*[M#2*

  22. etraut-openai commented on Sep 26, 2026

    @etraut-openai
    Contributor

    @tleneel, please file a new bug report with the details requested in the bug template.

  23. gravitydeepimpactsun commented on Sep 27, 2026

    @gravitydeepimpactsun
    PS C:\Users\Admin\Documents\Project> codex
    Installing daemon from CLI version 0.157.1 into C:\Users\Admin\.codex\packages/app-server-daemon...
    Error: Access is denied. (os error 5)
    To work without the background server, rerun the same command with --no-daemon (including resume or fork and its arguments).
    

    @etraut-openai Still happening after updating.

  24. lain804 commented on Sep 27, 2026

    @lain804

    @etraut-openai

    i can confirm this is still the case on 157.1 and is fixed by downgrading to 0.156, im running on windows 10

    > codex --version
    codex-cli 0.157.1
    
    > codex
    Error: cannot launch detached daemon; existing daemon was not stopped: The requested operation requires elevation. (os error 740)
    To work without the background server, rerun the same command with --no-daemon (including resume or fork and its arguments).
    

    running the cmd prompt/powershell as admin does not fix it and neither does setting this checkbox

    Image

    in the codex binaries folder

    please reopen this issue as i believe it is affecting most windows users

  25. radmi03 commented on Sep 28, 2026

    @radmi03

    Confirming the Windows regression is still reproducible on Codex CLI 0.157.1.

    Observed on Windows:

    • codex -> Installing daemon from CLI version 0.157.1 ... then Error: Access is denied. (os error 5)
    • codex --no-daemon works
    • Target directory is writable: create/delete/rename tests all succeed
    • ACL inheritance is enabled; normal file operations under CODEX_HOME\packages succeed
    • The installer creates app-server-daemon\releases and install.lock, but no daemon binary is extracted before the failure
    • Downgrading to @openai/codex@0.156.1 fixes the issue; normal codex with daemon works again

    This strongly suggests a 0.157.x Windows daemon installation/startup regression rather than a local NTFS permission problem.

  26. vidi42 commented on Sep 28, 2026

    @vidi42

    @etraut-openai
    I just upgraded to 0.158.0 and got this warning

    Image

    Then I try to upgrade the daemon and end up with this issue

    >codex
    Updating the local background server...
    Error: host Job Object prevents daemon detachment; start from a host that allows breakaway
    Error: Daemon update failed with status exit code: 1
    
  27. leobrqz commented on Sep 28, 2026

    @leobrqz

    same issue in the latest update

    npm warn cleanup Failed to remove some directories [
    npm warn cleanup   [
    npm warn cleanup     'C:\\Users\\xxxx\\AppData\\Roaming\\npm\\node_modules\\@openai\\.codex-lTMVJigE',
    npm warn cleanup     [Error: EPERM: operation not permitted, unlink 'C:\Users\xxxx\AppData\Roaming\npm\node_modules\@openai\.codex-lTMVJigE\node_modules\@openai\codex-win32-x64\vendor\x86_64-pc-windows-msvc\bin\codex.exe'] {
    npm warn cleanup       errno: -4048,
    npm warn cleanup       code: 'EPERM',
    npm warn cleanup       syscall: 'unlink',
    npm warn cleanup       path: 'C:\\Users\\xxxx\\AppData\\Roaming\\npm\\node_modules\\@openai\\.codex-lTMVJigE\\node_modules\\@openai\\codex-win32-x64\\vendor\\x86_64-pc-windows-msvc\\bin\\codex.exe'
    npm warn cleanup     }
    npm warn cleanup   ]
    npm warn cleanup ]
    
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

    CLIIssues related to the Codex CLIapp-serverIssues involving app server protocol or interfacesbugSomething isn't workingwindows-osIssues related to Codex on Windows systems

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions