codex - 💡(How to fix) Fix Codex CLI local Responses provider disconnects when base_url uses localhost; works with 127.0.0.1

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Codex CLI local Responses provider fails when base_url uses localhost, but works when changed to 127.0.0.1.

Error Message

Stream disconnected before completion: error sending request for url (http://localhost:8000/v1/responses)

Root Cause

Codex CLI local Responses provider fails when base_url uses localhost, but works when changed to 127.0.0.1.

Fix Action

Fix / Workaround

Workaround Changing only the provider URL from localhost to 127.0.0.1 fixes the issue:

RAW_BUFFERClick to expand / collapse

What version of Codex CLI is running?

codex-cli 0.129.0

What subscription do you have?

pro

Which model were you using?

local, Qwen3 Coder Next Local

What platform is your computer?

Darwin 24.6.0 x86_64 i386

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

No response

What issue are you seeing?

Summary

Codex CLI local Responses provider fails when base_url uses localhost, but works when changed to 127.0.0.1.

Version

Codex CLI v0.129.0

Platform

macOS / Darwin

Configuration

I am using a custom local provider pointed at a vLLM OpenAI-compatible Responses endpoint:

[model_providers.qwen-local]
name = "Qwen3 Coder Next Local"
base_url = "http://localhost:8000/v1"
wire_api = "responses"

[profiles.local-qwen]
model_provider = "qwen-local"
model = "qwen3-coder-next"
model_reasoning_effort = "medium"
approval_policy = "never"


### What steps can reproduce the bug?

Reproduction
Start a local vLLM server listening on IPv4 localhost / 127.0.0.1:8000.
Configure Codex CLI provider with:
base_url = "http://localhost:8000/v1"
Launch:
codex --profile local-qwen --disable apps --disable plugins -a never
Send a simple prompt:
hello
Actual behavior
Codex TUI repeatedly reconnects and then fails:

Reconnecting... 5/5
Stream disconnected before completion: error sending request for url (http://localhost:8000/v1/responses)
The session log records the turn as completed with last_agent_message: null.

### What is the expected behavior?

Codex should successfully connect to the local provider using localhost, or at least handle IPv6-to-IPv4 fallback reliably.

Workaround
Changing only the provider URL from localhost to 127.0.0.1 fixes the issue:

[model_providers.qwen-local]
name = "Qwen3 Coder Next Local"
base_url = "http://127.0.0.1:8000/v1"
wire_api = "responses"
After this change, the same command works:

codex --profile local-qwen

### Additional information

curl showed that localhost resolves IPv6 first and then IPv4:

Trying [::1]:8000...
connect to ::1 failed
Trying 127.0.0.1:8000...
Connected
So this may be an IPv6 localhost fallback issue in Codex CLI’s HTTP client path, especially for streaming /v1/responses requests.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING