Quick Answer
A "request timed out" error from Codex means a request was sent but no response arrived within the allowed time. It is one of the most common Codex CLI frustrations, and it has a surprisingly small set of root causes: an unreachable endpoint, a misconfigured proxy, a request that is too large, a server-side slowdown, or a client timeout that is simply too short. The 7 fixes below solve all of them — and you can usually tell which one applies in under a minute.
For developers on restrictive networks, the single highest-leverage fix is to route Codex through a stable API gateway like TeamoRouter, which removes most of the network causes in one step. The rest of this article walks through every fix, from the fastest to the most thorough.
Before You Start: Which Kind of Timeout Is It?
Timeouts come in two flavors, and the fix differs.
- Client-side timeout: your machine gave up waiting. Look for messages like
Connection timeout after 30000ms,request timed out, orfetch failed. - Server-side timeout: the provider took too long to respond, often under heavy load. The client may report the same generic error, but the request actually reached the server.
The quickest way to separate them is a raw connectivity test:
curl -sS -o /dev/null -w "HTTP %{http_code} in %{time_total}s\n" \
https://api.openai.com/v1/models \
-H "Authorization: Bearer $OPENAI_API_KEY"
- Fast success (HTTP 200 in seconds) → the endpoint is fine; your Codex config or the specific request is the problem.
- Hang or connection error → your network cannot reach the endpoint at all.
- Success but slow (several seconds) → server latency; raise timeouts and add retries.
Fix 1: Confirm the Endpoint Is Reachable
Before touching any configuration, confirm you can reach the API at all. The curl above is the fastest check. If it fails, your network path is the problem and you should skip ahead to Fix 2 or Fix 3.
Also check whether other network-dependent tools work. If npm install is also slow or failing, the problem is your network, not Codex:
# If npm is also timing out, it is a network issue
npm ping
Fix 2: Configure Your Proxy Correctly
The Codex CLI runs in your terminal and uses the terminal's network stack. It does not automatically use your browser's proxy settings. If you use a proxy, you must export the proxy variables in the same shell where Codex runs:
export HTTPS_PROXY=http://127.0.0.1:7890
export HTTP_PROXY=http://127.0.0.1:7890
export ALL_PROXY=socks5://127.0.0.1:7890
export NO_PROXY=localhost,127.0.0.1
codex
Three common proxy mistakes that cause timeouts:
- Setting the proxy in your browser but not in the terminal where Codex runs.
- Setting an HTTPS proxy for a port that only listens as HTTP, or vice versa.
- A proxy that is up but cannot actually reach OpenAI (try
curlthrough it).
If a proxy variable is set and is wrong, it is worse than no proxy at all, because every request goes into a dead tunnel and waits for a timeout. For a clean test, unset all proxy variables and retry:
unset http_proxy https_proxy all_proxy HTTP_PROXY HTTPS_PROXY ALL_PROXY
codex "Say hello"
Fix 3: Route Through an API Gateway (The Durable Fix)
If you are outside a supported region, behind a restrictive firewall, or tired of proxy roulette, the most reliable fix is to route Codex through an API gateway. A gateway gives you an endpoint that is reachable from your network and forwards to OpenAI from stable infrastructure, so the "can't reach the API" class of timeouts disappears.
Configure it in Codex's config file:
# ~/.codex/config.toml
model = "gpt-5.6-codex"
model_provider = "teamo"
[model_providers.teamo]
name = "TeamoRouter"
base_url = "https://api.teamorouter.com/v1"
env_key = "TEAMO_API_KEY"
Then set the key and run:
export TEAMO_API_KEY=tr_xxxxxxxx
codex
Because the gateway terminates the connection at a reachable endpoint, it also fixes intermittent timeouts caused by flaky regional routing. This is the fix we recommend most to developers who see timeouts daily.
Fix 4: Increase the Client Timeout and Add Retries
Some timeouts are simply the client giving up too early. Long-running agent tasks — big refactors, repository-wide searches, or models that think for a while — can legitimately take longer than a default timeout.
For SDK users, raise the timeout explicitly. In Node.js:
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.OPENAI_API_KEY,
baseURL: process.env.OPENAI_BASE_URL, // optional gateway
timeout: 300_000, // 5 minutes instead of a short default
maxRetries: 3,
});
In Python:
from openai import OpenAI
client = OpenAI(
api_key=os.environ["OPENAI_API_KEY"],
base_url=os.environ.get("OPENAI_BASE_URL"),
timeout=300.0,
max_retries=3,
)
If you are using the Codex CLI directly, check whether your wrapper or script imposes its own timeout. A shell timeout wrapper, a CI job limit, or a reverse proxy in front of Codex can all cut a long request short.
Fix 5: Check Quota, Rate Limits, and Server-Side Load
A request that reaches the server can still time out if the server is overloaded or if you are being throttled. This is the "server-side" flavor mentioned above. Signs include:
- Timeouts mostly happen during peak hours or on popular models.
- The timeout appears after a long wait rather than instantly.
- Other requests succeed moments before or after the failed one.
Check your usage dashboard for rate-limit or quota warnings. If you are hitting limits, the fix is not a network change — it is to raise your tier, wait for a reset, or route through a provider with spare capacity. A gateway that balances across upstream providers can also absorb peak-hour slowness on a single provider.
Fix 6: Reduce Request Size and Clear Stale State
Very large requests can exceed payload limits or take long enough to look like a timeout. Three practical reductions:
- Trim the conversation/context you send. If you are including a huge file or a long history, narrow it to what the task actually needs.
- Clear Codex's cached state. Stale session or auth caches can cause weird failures:
# Re-authenticate and clear local session state
codex logout
codex login
- Restart the daemon/agent. If Codex runs a local server, restart it so in-memory state is reset.
The goal is to rule out "the request was just too heavy" before chasing network causes.
Fix 7: Update Codex CLI and Re-authenticate
An outdated CLI can carry bugs that were fixed in later releases, and an expired auth token can produce confusing failures that look like timeouts. Two quick commands handle both:
# Update to the latest version
npm install -g @openai/codex@latest
# Refresh authentication
codex login
After updating, verify the version and re-run your request. A surprising number of "request timed out" reports on older versions disappear after an update, because the newer client sends better timeouts, retries, and connection reuse.
The 7 Fixes at a Glance
| # | Fix | Solves | Effort |
|---|---|---|---|
| 1 | Confirm endpoint reachability | All cases (diagnosis) | 1 min |
| 2 | Configure terminal proxy | Network-path timeouts | 5 min |
| 3 | Route via API gateway | Regional/restrictive-network timeouts | 10 min |
| 4 | Raise client timeout + retries | Long-running tasks | 5 min |
| 5 | Check quota/rate limits | Server-side throttling | 5 min |
| 6 | Reduce request size / clear state | Oversized requests | 5 min |
| 7 | Update CLI and re-authenticate | Stale-client bugs | 5 min |
How TeamoRouter Fits In
If timeouts are a recurring problem rather than a one-off, the durable answer is to stop depending on your local network reaching OpenAI directly. TeamoRouter provides a stable API gateway endpoint that works from restrictive networks, keeps your Codex config simple, and can route around a slow or overloaded upstream. It is not a band-aid for a single timeout — it removes the entire class of network-induced timeouts from your day.
Frequently Asked Questions
Is a timeout the same as a block?
No. A timeout means your request was sent but no response arrived in time. A block means the request was refused before processing (region, IP, or auth issues). The two need different fixes — a faster timeout config will not fix a block, and a gateway will not fix a timeout caused by an oversized request.
Why does Codex time out only sometimes?
Intermittent timeouts usually point to load, throttling, or flaky routing rather than a hard misconfiguration. Try Fix 5 (check quota/rate limits) and Fix 3 (route through a gateway) together; a gateway absorbs upstream variance by balancing across providers.
What timeout value should I set?
There is no universal value. Short interactive prompts may complete in seconds, while big refactors can take minutes. A reasonable starting point is 120–300 seconds with retries enabled, then tune based on the longest task you actually run.
Can too many retries make things worse?
Yes. If the endpoint is genuinely down or blocked, aggressive retries just extend the wait. Keep retries modest (2–3) and let the error surface so you can diagnose the root cause instead of looping.
Will a VPN fix Codex timeouts?
Sometimes, if the timeout is caused by regional routing. But a flaky VPN can also cause timeouts. The more reliable fix is to route through an API gateway that gives you a stable, reachable endpoint rather than depending on a tunnel.
Bottom Line
"Codex request timed out" has a short list of causes, and the fix depends on which kind you are seeing. Start with the one-minute curl diagnostic, apply Fix 2 and Fix 4 for the common client-side cases, and if you are on a restrictive network, go straight to Fix 3 and route through an API gateway. In most cases you will be back to coding within minutes — and with a gateway in place, the problem stops coming back. Try the gateway route and see whether your timeouts disappear.