Codex cannot cURL localhost APIs

Resolved 💬 6 comments Opened Sep 26, 2025 by koshyviv Closed Jan 17, 2026
💡 Likely answer: A maintainer (seratch, member) responded on this thread — see the highlighted reply below.

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_

View original on GitHub ↗

6 Comments

seratch member · 11 months ago

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.

koshyviv · 11 months ago

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
koshyviv · 11 months ago

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.

corpuser · 10 months ago

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
jrmlhermitte · 10 months ago

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

etraut-openai contributor · 7 months ago

Closing out old bugs.