Skip to content

Codex cannot cURL localhost APIs #4279

Closed

Description

@koshyviv

What version of Codex is running?

codex-cli 0.39.0

Which model were you using?

gpt-5-codex

What platform is your computer?

Linux 5.15.167.4-microsoft-standard-WSL2 x86_64 x86_64

What steps can reproduce the bug?

just asked it to hit localhost:8081

What is the expected behavior?

It should be able to print the response of the local API

koshy@hp:~$ curl localhost:8081
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Cannot GET /</pre>
</body>
</html>

What do you see instead?

• Ran curl localhost:8081
  └   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
    0
    curl: (7) Failed to connect to localhost port 8081 after 0 ms: Couldn't connect to server

> Ran curl localhost:8081 in this environment and it still returns curl: (7) Failed to connect to localhost port 8081; there’s no listener on 8081 inside
  the sandbox.

Additional information

No response

Activity

  1. seratch commented on Sep 26, 2025

    @seratch
    Member

    Adding network_access = false to your $HOME/.codex/config.toml may help. Refer to https://github.com/openai/codex/blob/main/docs/config.md for more details.

  2. koshyviv commented on Sep 26, 2025

    @koshyviv
    Author

    That didnt help either

    ⋊> ~/c/tr on dev ⨯ codex                                                                                                         (base) 12:59:13
    ╭────────────────────────────────────────────────╮
    │ >_ OpenAI Codex (v0.41.0)                      │
    │                                                │
    │ model:     gpt-5-codex high   /model to change │
    │ directory: ~/code/tr                 │
    ╰────────────────────────────────────────────────╯
    
      To get started, describe a task or try one of these commands:
    
      /init - create an AGENTS.md file with instructions for Codex
      /status - show current session configuration
      /approvals - choose what Codex can do without approval
      /model - choose what model and reasoning effort to use
    
    ▌ can you try `curl localhost:8081`
    
    • Ran curl localhost:8081
      └   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                         Dload  Upload   Total   Spent    Left  Speed
      0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
        0
        curl: (7) Failed to connect to localhost port 8081 after 0 ms: Couldn't connect to server
    
    > curl localhost:8081 couldn’t connect—connection refused on port 8081. If something should be running there, make sure the service is up first.
    
    ▌ Implement {feature}                                                                                                                                     
    

    tried with both network_access = false and network_access = true

    config.toml

    ⋊> ~/c/tr on dev ⨯ cat $HOME/.codex/config.toml                                                                                  (base) 13:00:17
    model = "gpt-5-codex"
    model_reasoning_effort = "high"
    [projects."/home/koshy/code/tr"]
    trust_level = "trusted"
    
    [projects."/home/koshy/code/lt"]
    trust_level = "trusted"
    
    network_access = false
    
  3. koshyviv commented on Sep 26, 2025

    @koshyviv
    Author

    I was able to run with this codex --sandbox danger-full-access - but seems a little too unsafe if im directly running it on my laptop.

  4. changed the title [-]Codex cannot cURL[/-] [+]Codex cannot cURL localhost APIs[/+] on Sep 26, 2025
  5. corpuser commented on Oct 13, 2025

    @corpuser

    Figured this out, @koshyviv your config should be this instead

    model = "gpt-5-codex"
    model_reasoning_effort = "high"
    [projects."/home/koshy/code/tr"]
    trust_level = "trusted"
    
    [projects."/home/koshy/code/lt"]
    trust_level = "trusted"
    
    
    [sandbox_workspace_write]
    network_access = true
    
  6. jrmlhermitte commented on Oct 23, 2025

    @jrmlhermitte

    I ran into this for for a python test. I believe it's a similar issue. See comment here

  7. etraut-openai commented on Jan 17, 2026

    @etraut-openai
    Contributor

    Closing out old bugs.

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

    bugSomething isn't workingsandboxIssues related to permissions or sandboxingwindows-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