Recently, while using Codex, I encountered a very annoying problem: every time I execute /new, it first tries to reconnect 5 times before finally starting to respond normally after a long wait.

After searching around, I finally found a solution and will document it here.


Solution Steps

1. Locate the Configuration File

Navigate to the Codex installation directory and find:

config.toml

Please enter image description


2. Modify the Configuration

Open config.toml and add the following content (note the use of English quotes):

Add at the very top of the file:

model_provider = "openai_https"

Add at the very bottom of the file:

[model_providers.openai_https]
name = "OpenAI"
wire_api = "responses"
requires_openai_auth = true
supports_websockets = false

3. Restart Codex

After saving the file, restart Codex for the changes to take effect.


Explanation of the Cause

By default, Codex uses the WebSocket protocol for communication:

  • It first attempts to connect via WebSocket.
  • If it fails, it automatically reconnects 5 times.
  • Each timeout is approximately 20 seconds.
  • Finally, it falls back to HTTP.

    This is why you experience the "long wait before responding" situation.

The configuration above essentially does the following:

✅ Forces the use of HTTP (disables WebSocket)

Important Notes

There will be a minor side effect after the modification:

  • Your history records will appear "missing" (though they are not actually deleted).

The reason is:

  • Codex distinguishes between built-in providers and custom providers.
  • History records are bound to their respective providers.
  • We have essentially added a new provider.

    Solution:

  • To view your history → simply remove this configuration section to restore it.

Reference Documentation

GitHub Issue:
https://github.com/openai/codex/issues/14297

END

本文标题:解决 Codex 每次 Reconnecting 5 次才响应的问题

本文链接:https://www.imsuk.cn/archives/276/

除非另有说明,本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议

声明:转载请注明文章来源。

Last modification:April 25, 2026
请用钱砸我