Skip to content

dotnet command hangs until timeout, with high cpu #3269

Open

Description

@joakimriedel

What version of Codex is running?

0.30.0

Which model were you using?

gpt-5-high

What platform is your computer?

Darwin 24.6.0 arm64 arm

What steps can reproduce the bug?

ask codex to run dotnet test, it will respond something like

run dotnet test directly

> Running .NET tests directly for the solution (no restore). This may take a
  few minutes.

• Ran
  └ dotnet test ./<solution>.sln --no-restore -v minimal

<here I press escape due to no progress after minutes..>

🖐  Tell the model what to do differently

I cancelled after several minutes. Looking in Activity Monitor, the dotnet process consumes ~50% cpu and seems to get nowhere. If I run the exact same command (copying from codex and running in separate terminal) it completes successfully in 11 seconds.

I have no clue what is happening here, but I also have similar issues running vitest from codex from npm npm run test, it just completely hogs my computer and I have to force quit.

Is anyone else managing to run dotnet and vitest using codex? My commands work flawlessly in Claude Code, so I know it is not my tests that are failing, it is something about how codex call the commands that seems off.

What is the expected behavior?

Codex should call dotnet, npm or vitest commands successfully.

What do you see instead?

Hangs (if I don't press escape, it auto-timeouts after like 10 minutes)

Additional information

No response

Activity

  1. added
    bug
    on Sep 7, 2025
  2. added
    windows-os
    on Sep 8, 2025
  3. joakimriedel commented on Sep 10, 2025

    @joakimriedel
    Author

    I saw the windows-os tag but this is macOS 15.6.1

  4. asafyish commented on Sep 11, 2025

    @asafyish

    I can confirm it also happens on mac. there were several node process, consuming all my system memory, swap was at 24gb, had to restart with the power button. I restart codex every few tasks to have fresh context, the processes are still there.

    Also using vitest.

  5. danyo1399 commented on Sep 16, 2025

    @danyo1399

    Same issue for me dotnet build on Mac never finishes making codex for dotnet useless because it can’t check for errors

  6. danyo1399 commented on Sep 16, 2025

    @danyo1399

    dotnet build hangs when codex runs it however if i set access to full access it builds fine

  7. joakimriedel commented on Sep 16, 2025

    @joakimriedel
    Author

    Thanks for that note on enabling full access. It turns out codex 0.36.0 has an improved error message;

    ▌ run dotnet test to test the backend code
    
    • Ran dotnet test
    
    • Explored
      └ List ls
    
    • Ran dotnet test <solution>.sln
      └ Unhandled exception. System.Net.Sockets.SocketException (13): Permission
        denied
           at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot,
        SocketAddress socketAddress)
           at System.Net.Sockets.Socket.Bind(EndPoint localEP)
           at System.IO.Pipes.NamedPipeServerStream.SharedServer..ctor(String path,
        Int32 maxCount, Boolean isFirstPipeInstance)
           at System.IO.Pipes.NamedPipeServerStream.SharedServer.Get(String path,
        Int32 maxCount, PipeOptions pipeOptions)
        … +81 lines
           at Microsoft.Build.Execution.OutOfProcNode.Run(Boolean enableReuse,
        Boolean lowPriority, Exception& shutdownException)
           at
        Microsoft.Build.CommandLine.MSBuildApp.StartLocalNode(CommandLineSwitches
        commandLineSwitches, Boolean lowpriority)
           at
        Microsoft.Build.CommandLine.MSBuildApp.ProcessCommandLineSwitches(CommandLin
        eSwitches switchesFromAutoResponseFile, CommandLineSwitches
        switchesNotFromAutoResponseFile, String& projectFile, String[]& targets,
        String& toolsVersion, Dictionary`2& globalProperties, ILogger[]& loggers,
        LoggerVerbosity& verbosity, LoggerVerbosity& originalVerbosity, List`1&
        distributedLoggerRecords, Int32& cpuCount, Boolean& enableNodeReuse,
        TextWriter& preprocessWriter, TextWriter& targetsWriter, Boolean&
        detailedSummary, ISet`1& warningsAsErrors, ISet`1& warningsNotAsErrors,
        ISet`1& warningsAsMessages, Boolean& enableRestore, Boolean& interactive,
        ProfilerLogger& profilerLogger, Boolean& enableProfiler, Dictionary`2&
        restoreProperties, ProjectIsolationMode& isolateProjects, GraphBuildOptions&
        graphBuild, String[]& inputResultsCaches, String& outputResultsCache,
        Boolean& lowPriority, Boolean& question, Boolean& isBuildCheckEnabled,
        String[]& getProperty, String[]& getItem, String[]& getTargetResult, String&
        getResultOutputFile, Boolean recursing, String commandLine)
           at Microsoft.Build.CommandLine.MSBuildApp.Execute(String[] commandLine)
           at Microsoft.Build.CommandLine.MSBuildApp.Main(String[] args)
    
    • Ran
      └ DOTNET_CLI_ENABLE_MSBUILD_SERVER=0 MSBUILDDISABLENODEREUSE=1 dotnet test
            <solution>.sln
        Unhandled exception. System.Net.Sockets.SocketException (13): Permission
        denied
           at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot,
        SocketAddress socketAddress)
           at System.Net.Sockets.Socket.Bind(EndPoint localEP)
           at System.IO.Pipes.NamedPipeServerStream.SharedServer..ctor(String path,
        Int32 maxCount, Boolean isFirstPipeInstance)
           at System.IO.Pipes.NamedPipeServerStream.SharedServer.Get(String path,
        Int32 maxCount, PipeOptions pipeOptions)
        … +900 lines
           at Microsoft.Build.Execution.OutOfProcNode.Run(Boolean enableReuse,
        Boolean lowPriority, Exception& shutdownException)
           at
        Microsoft.Build.CommandLine.MSBuildApp.StartLocalNode(CommandLineSwitches
        commandLineSwitches, Boolean lowpriority)
           at
        Microsoft.Build.CommandLine.MSBuildApp.ProcessCommandLineSwitches(CommandLin
        eSwitches switchesFromAutoResponseFile, CommandLineSwitches
        switchesNotFromAutoResponseFile, String& projectFile, String[]& targets,
        String& toolsVersion, Dictionary`2& globalProperties, ILogger[]& loggers,
        LoggerVerbosity& verbosity, LoggerVerbosity& originalVerbosity, List`1&
        distributedLoggerRecords, Int32& cpuCount, Boolean& enableNodeReuse,
        TextWriter& preprocessWriter, TextWriter& targetsWriter, Boolean&
        detailedSummary, ISet`1& warningsAsErrors, ISet`1& warningsNotAsErrors,
        ISet`1& warningsAsMessages, Boolean& enableRestore, Boolean& interactive,
        ProfilerLogger& profilerLogger, Boolean& enableProfiler, Dictionary`2&
        restoreProperties, ProjectIsolationMode& isolateProjects, GraphBuildOptions&
        graphBuild, String[]& inputResultsCaches, String& outputResultsCache,
        Boolean& lowPriority, Boolean& question, Boolean& isBuildCheckEnabled,
        String[]& getProperty, String[]& getItem, String[]& getTargetResult, String&
        getResultOutputFile, Boolean recursing, String commandLine)
           at Microsoft.Build.CommandLine.MSBuildApp.Execute(String[] commandLine)
           at Microsoft.Build.CommandLine.MSBuildApp.Main(String[] args)
    
    > Tried dotnet test <solution>.sln (with
      DOTNET_CLI_ENABLE_MSBUILD_SERVER=0 and MSBUILDDISABLENODEREUSE=1 to avoid
      MSBuild server), but the run failed immediately: MSBuild can’t create its
      named pipe endpoints in this sandbox (System.Net.Sockets.SocketException (13):
      Permission denied). Tests didn’t execute. If you can run outside the sandbox
      (or permit named pipes), rerun the same command from the repo root.
    

    So I went into config.toml and set

    [sandbox_workspace_write]
    network_access = true

    Now the same command rendered the following output;

    run dotnet test to test backend code
    
    • Ran dotnet test
    
    • Explored
      └ List ls
        List ls
    
    • Ran dotnet test <solution>.sln
      └ Unhandled exception. System.Net.Sockets.SocketException (13): Permission
        denied
           at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot,
        SocketAddress socketAddress)
           at System.Net.Sockets.Socket.Bind(EndPoint localEP)
           at System.IO.Pipes.NamedPipeServerStream.SharedServer..ctor(String path,
        Int32 maxCount, Boolean isFirstPipeInstance)
           at System.IO.Pipes.NamedPipeServerStream.SharedServer.Get(String path,
        Int32 maxCount, PipeOptions pipeOptions)
        … +81 lines
           at Microsoft.Build.Execution.OutOfProcNode.Run(Boolean enableReuse,
        Boolean lowPriority, Exception& shutdownException)
           at
        Microsoft.Build.CommandLine.MSBuildApp.StartLocalNode(CommandLineSwitches
        commandLineSwitches, Boolean lowpriority)
           at
        Microsoft.Build.CommandLine.MSBuildApp.ProcessCommandLineSwitches(CommandLin
        eSwitches switchesFromAutoResponseFile, CommandLineSwitches
        switchesNotFromAutoResponseFile, String& projectFile, String[]& targets,
        String& toolsVersion, Dictionary`2& globalProperties, ILogger[]& loggers,
        LoggerVerbosity& verbosity, LoggerVerbosity& originalVerbosity, List`1&
        distributedLoggerRecords, Int32& cpuCount, Boolean& enableNodeReuse,
        TextWriter& preprocessWriter, TextWriter& targetsWriter, Boolean&
        detailedSummary, ISet`1& warningsAsErrors, ISet`1& warningsNotAsErrors,
        ISet`1& warningsAsMessages, Boolean& enableRestore, Boolean& interactive,
        ProfilerLogger& profilerLogger, Boolean& enableProfiler, Dictionary`2&
        restoreProperties, ProjectIsolationMode& isolateProjects, GraphBuildOptions&
        graphBuild, String[]& inputResultsCaches, String& outputResultsCache,
        Boolean& lowPriority, Boolean& question, Boolean& isBuildCheckEnabled,
        String[]& getProperty, String[]& getItem, String[]& getTargetResult, String&
        getResultOutputFile, Boolean recursing, String commandLine)
           at Microsoft.Build.CommandLine.MSBuildApp.Execute(String[] commandLine)
           at Microsoft.Build.CommandLine.MSBuildApp.Main(String[] args)
    
    • Proposed Command
      └ dotnet test <solution>.sln
    
    dotnet test needs named pipes which sandbox blocks; running without sandbox
    allows backend tests to complete
    
    ▌Allow command?
    ▌ Yes   Always   No, provide feedback 
    ▌ Approve and run the command       
    
    You approved codex to run dotnet test <solution>.sln
    every time this session
    
    • Ran dotnet test <solution>.sln
    

    So allowing network access seems to be a workaround for running dotnet commands in codex. I still think this default behaviour is not very user friendly and confusing coming from Claude Code where dotnet commands run out of the box. I am also unsure what security implications this have for me enabling network access in the sandbox mode.

  8. mistial-dev commented on Sep 17, 2025

    @mistial-dev

    This hanging has been a problem for me for some time.

  9. alex-fitplans commented on Sep 21, 2025

    @alex-fitplans

    I confirm that running it in full access fixes the problem! Thanks @danyo1399

  10. cyril265 commented on Sep 23, 2025

    @cyril265

    dotnet test doesnt work even with workspace-write and network access:

    
    sandbox_mode = "workspace-write"
    [sandbox_workspace_write]
    network_access = true
    

    output:

    $ bash -lc 'dotnet test'
    MSBUILD : error MSB1025: An internal failure occurred while running MSBuild.
    System.Net.Sockets.SocketException (13): Permission denied
       at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
       at System.Net.Sockets.Socket.Bind(EndPoint localEP)
       at System.IO.Pipes.NamedPipeServerStream.SharedServer..ctor(String path, Int32 maxCount, Boolean isFirstPipeInstance)
       at System.IO.Pipes.NamedPipeServerStream.SharedServer.Get(String path, Int32 maxCount, PipeOptions pipeOptions)
       at System.IO.Pipes.NamedPipeServerStream.Create(String pipeName, PipeDirection direction, Int32 maxNumberOfServerInstances, PipeTransmissionMode transmissionMode, PipeOptions options, Int32 inBufferSize, Int32 outBufferSize, HandleInheritability inheritability)
       at System.IO.Pipes.NamedPipeServerStream..ctor(String pipeName, PipeDirection direction, Int32 maxNumberOfServerInstances, PipeTransmissionMode transmissionMode, PipeOptions options, Int32 inBufferSize, Int32 outBufferSize)
       at Microsoft.Build.BackEnd.NodeEndpointOutOfProcBase.InternalConstruct(String pipeName)
       at Microsoft.Build.Execution.OutOfProcNode.Run(Boolean enableReuse, Boolean lowPriority, Exception& shutdownException)
       at Microsoft.Build.CommandLine.MSBuildApp.StartLocalNode(CommandLineSwitches commandLineSwitches, Boolean lowpriority)
       at Microsoft.Build.CommandLine.MSBuildApp.ProcessCommandLineSwitches(CommandLineSwitches switchesFromAutoResponseFile, CommandLineSwitches switchesNotFromAutoResponseFile, String& projectFile, String[]& targets, String& toolsVersion, Dictionary`2& globalProperties, ILogger[]& loggers, LoggerVerbosity& verbosity, LoggerVerbosity& originalVerbosity, List`1& distributedLoggerRecords, Int32& cpuCount, Boolean& enableNodeReuse, TextWriter& preprocessWriter, TextWriter& targetsWriter, Boolean& detailedSummary, ISet`1& warningsAsErrors, ISet`1& warningsNotAsErrors, ISet`1& warningsAsMessages, Boolean& enableRestore, Boolean& interactive, ProfilerLogger& profilerLogger, Boolean& enableProfiler, Dictionary`2& restoreProperties, ProjectIsolationMode& isolateProjects, GraphBuildOptions& graphBuild, String[]& inputResultsCaches, String& outputResultsCache, Boolean& lowPriority, Boolean& question, Boolean& isBuildCheckEnabled, String[]& getProperty, String[]& getItem, String[]& getTargetResult, String& getResultOutputFile, Boolean recursing, String commandLine)
       at Microsoft.Build.CommandLine.MSBuildApp.Execute(String[] commandLine)
    Unhandled exception. System.Net.Sockets.SocketException (13): Permission denied
       at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
       at System.Net.Sockets.Socket.Bind(EndPoint localEP)
       at System.IO.Pipes.NamedPipeServerStream.SharedServer..ctor(String path, Int32 maxCount, Boolean isFirstPipeInstance)
       at System.IO.Pipes.NamedPipeServerStream.SharedServer.Get(String path, Int32 maxCount, PipeOptions pipeOptions)
       at System.IO.Pipes.NamedPipeServerStream.Create(String pipeName, PipeDirection direction, Int32 maxNumberOfServerInstances, PipeTransmissionMode transmissionMode, PipeOptions options, Int32 inBufferSize, Int32 outBufferSize, HandleInheritability inheritability)
       at System.IO.Pipes.NamedPipeServerStream..ctor(String pipeName, PipeDirection direction, Int32 maxNumberOfServerInstances, PipeTransmissionMode transmissionMode, PipeOptions options, Int32 inBufferSize, Int32 outBufferSize)
       at Microsoft.Build.BackEnd.NodeEndpointOutOfProcBase.InternalConstruct(String pipeName)
       at Microsoft.Build.Execution.OutOfProcNode.Run(Boolean enableReuse, Boolean lowPriority, Exception& shutdownException)
       at Microsoft.Build.CommandLine.MSBuildApp.StartLocalNode(CommandLineSwitches commandLineSwitches, Boolean lowpriority)
       at Microsoft.Build.CommandLine.MSBuildApp.ProcessCommandLineSwitches(CommandLineSwitches switchesFromAutoResponseFile, CommandLineSwitches switchesNotFromAutoResponseFile, String& projectFile, String[]& targets, String& toolsVersion, Dictionary`2& globalProperties, ILogger[]& loggers, LoggerVerbosity& verbosity, LoggerVerbosity& originalVerbosity, List`1& distributedLoggerRecords, Int32& cpuCount, Boolean& enableNodeReuse, TextWriter& preprocessWriter, TextWriter& targetsWriter, Boolean& detailedSummary, ISet`1& warningsAsErrors, ISet`1& warningsNotAsErrors, ISet`1& warningsAsMessages, Boolean& enableRestore, Boolean& interactive, ProfilerLogger& profilerLogger, Boolean& enableProfiler, Dictionary`2& restoreProperties, ProjectIsolationMode& isolateProjects, GraphBuildOptions& graphBuild, String[]& inputResultsCaches, String& outputResultsCache, Boolean& lowPriority, Boolean& question, Boolean& isBuildCheckEnabled, String[]& getProperty, String[]& getItem, String[]& getTargetResult, String& getResultOutputFile, Boolean recursing, String commandLine)
       at Microsoft.Build.CommandLine.MSBuildApp.Execute(String[] commandLine)
       at Microsoft.Build.CommandLine.MSBuildApp.Main(String[] args)
    
  11. joakimriedel commented on Sep 24, 2025

    @joakimriedel
    Author

    @cyril265 codex is not very consistent here, sometimes it asks for elevated network access after setting sandboxed network access, sometimes not. I usually have to remember it to ask me - something like this to get the "Allow Access" prompt;

    • Ran dotnet build <solution>.sln
    
    ■ Conversation interrupted - tell the model what to do differently
    
    ▌ build needs network access, ask me to elevate permission
    
    • Proposed Command
      └ dotnet build <solution>.sln
    
    ✔ You approved codex to run dotnet build <solution>.sln every time this session
    
  12. cyril265 commented on Sep 24, 2025

    @cyril265

    I agree. Codex appears to struggle with knowing when to request elevated permissions, leading to prolonged retries and occasional edits to unrelated items.
    Perhaps this can be fixed broadly, eliminating the need for additional prompts.

  13. mistial-dev commented on Sep 24, 2025

    @mistial-dev

    @cyril265 codex is not very consistent here, sometimes it asks for elevated network access after setting sandboxed network access, sometimes not. I usually have to remember it to ask me - something like this to get the "Allow Access" prompt;

    • Ran dotnet build <solution>.sln
    
    ■ Conversation interrupted - tell the model what to do differently
    
    ▌ build needs network access, ask me to elevate permission
    
    • Proposed Command
      └ dotnet build <solution>.sln
    
    ✔ You approved codex to run dotnet build <solution>.sln every time this session
    

    It would be handy to be able to give conditional reminders to the LLM when it runs specific tasks, including a "are you sure" when it's running something potentially destructive.

  14. Artein commented on Oct 15, 2025

    @Artein

    Yes, running with sandbox_mode = "danger-full-access" is the only solution.
    Without it, there is no agentic loop in Codex on .Net projects, which is sad

  15. AndrewNikolin commented on Oct 30, 2025

    @AndrewNikolin
    Contributor

    Only found this issue now, but seems like i had the same problem on codex 0.50.0 in #5946
    Thanks for tips in previous comments, running the same in full access mode finally worked. Yet i believe this should be fixed to work in regular permission auto-mode too

  16. AndrewNikolin commented on Oct 31, 2025

    @AndrewNikolin
    Contributor

    remember it to ask me

    I solved this by modifying agents.md file to tell it to request elevated permissions, worked like a charm. Hope there will eventually be a broader fix

  17. joakimriedel commented on Oct 31, 2025

    @joakimriedel
    Author

    @AndrewNikolin yes, I find it responds even better to be explicit in AGENTS.md by including the actual internal flag Codex needs to use;

    These commands will need network access and inside your sandbox you always have to run those commands
    with `with_escalated_permissions: true` on the `shell` tool call and include a one-sentence justification
    (e.g., "Need network access for npm install/build").
    Ensure to include the `with_escalated_permissions` for all builds, restores, migrations, installs, tests, etc
    where network access is required otherwise the command will hang.
    

    That said, when Codex escalates, it would be nice if it was possible to make the approval last more than this session similar to Claude Code it would be a huge QOL to make it last the approval for all future sessions as well.

    You approved codex to run npm run lint every time this session

    =>

    You approved codex to run npm run lint every time for future sessions

  18. mehmettaskiner commented on Nov 3, 2025

    @mehmettaskiner

    Similar issue is happening for me using VSCode extension with WSL2 on Win11. I have a python repo, where I have pytest suite using asyncio and sqlite, following snippet can be used to reproduce.

    $ bash -lc 'python3 - <<'"'"'PY'"'"'
    import asyncio
    from sqlalchemy.ext.asyncio import create_async_engine
    
    async def main():
        engine = create_async_engine('"'"'sqlite+aiosqlite:///:memory:'"'"')
        async with engine.begin() as conn:
            await asyncio.sleep(0.1)
        await engine.dispose()
        print('"'"'done'"'"')
    
    asyncio.run(main())
    PY'
    done
    

    without full access, test hangs on the db connection stages, but with @joakimriedel suggestion, if I put in in the agents.md to make codex ask for elevated access, it remembers to ask elevated permissions but feels like it should work in sandbox without full access.

  19. BowTiedCrocodile commented on Nov 11, 2025

    @BowTiedCrocodile

    These commands will need network access and inside your sandbox you always have to run those commands
    with with_escalated_permissions: true on the shell tool call and include a one-sentence justification
    (e.g., "Need network access for npm install/build").
    Ensure to include the with_escalated_permissions for all builds, restores, migrations, installs, tests, etc
    where network access is required otherwise the command will hang.

    This solved my issue, thanks!

  20. AndrewNikolin commented on Dec 9, 2025

    @AndrewNikolin
    Contributor

    Wanted to share here as well, 0.66.0 update makes this less painful: after command is remembered as "always allow" the timeouts and other related issues don't happen. On mac os that is stored in ~/.codex/policy/default.codexpolicy so i guess one can add patterns beforehand

  21. added
    tool-calls
    on Mar 16, 2026
  22. ShinChven commented on Apr 2, 2026

    @ShinChven

    same issue on macOS

  23. rafakwolf commented on Jun 24, 2026

    @rafakwolf

    same issue

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

Metadata

Metadata

Assignees

Labels

bugtool-callswindows-os

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions