codex - 💡(How to fix) Fix codex takes ~5 seconds before entering the TUI [1 comments, 2 participants]

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…
GitHub stats
openai/codex#19802Fetched 2026-04-28 06:36:52
View on GitHub
Comments
1
Participants
2
Timeline
7
Reactions
0
Author
Participants
Timeline (top)
labeled ×4closed ×1commented ×1unlabeled ×1

Root Cause

The codex found the cause by itself:

  • The delay happens before the first Codex log line is written to ~/.codex/log/codex-tui.log.
  • codex --disable plugins -c check_for_update_on_startup=false does not help
  • CODEX_TUI_DISABLE_KEYBOARD_ENHANCEMENT=1 codex does not help
  • sample cmd shows the main thread spending most samples in macOS hostname resolution
    • DNS capture shows repeated mDNS queries for the local hostname
      • A/AAAA <local-hostname>.local. via 224.0.0.251:5353 / ff02::fb:5353

Fix Action

Workaround

Adding the local hostname to /etc/hosts fixes the startup delay:

127.0.0.1 <local-hostname>.local
::1       <local-hostname>.local

After flushing DNS cache and restarting mDNSResponder, codex starts normally again:

sudo dscacheutil -flushcache
sudo killall -HUP mDNSResponder

Code Example

127.0.0.1 <local-hostname>.local
::1       <local-hostname>.local

---

sudo dscacheutil -flushcache
sudo killall -HUP mDNSResponder
RAW_BUFFERClick to expand / collapse

What version of Codex CLI is running?

codex-cli 0.125.0

What subscription do you have?

not related

Which model were you using?

not related

What platform is your computer?

Darwin 25.3.0 arm64 arm

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

Alacritty

What issue are you seeing?

After upgrading codex, launching codex takes ~5 seconds before entering the TUI. Before the upgrade there's no delay.

What steps can reproduce the bug?

Upgrading codex and launching it.

What is the expected behavior?

No delay on launching codex.

Additional information

Cause

The codex found the cause by itself:

  • The delay happens before the first Codex log line is written to ~/.codex/log/codex-tui.log.
  • codex --disable plugins -c check_for_update_on_startup=false does not help
  • CODEX_TUI_DISABLE_KEYBOARD_ENHANCEMENT=1 codex does not help
  • sample cmd shows the main thread spending most samples in macOS hostname resolution
    • DNS capture shows repeated mDNS queries for the local hostname
      • A/AAAA <local-hostname>.local. via 224.0.0.251:5353 / ff02::fb:5353

Workaround

Adding the local hostname to /etc/hosts fixes the startup delay:

127.0.0.1 <local-hostname>.local
::1       <local-hostname>.local

After flushing DNS cache and restarting mDNSResponder, codex starts normally again:

sudo dscacheutil -flushcache
sudo killall -HUP mDNSResponder

extent analysis

TL;DR

Adding the local hostname to /etc/hosts and flushing the DNS cache may resolve the startup delay issue with Codex CLI.

Guidance

  • The delay is likely caused by repeated mDNS queries for the local hostname, which can be verified by checking the DNS capture and codex-tui.log for related errors.
  • To mitigate the issue, add the local hostname to /etc/hosts with the following entries: 127.0.0.1 <local-hostname>.local and ::1 <local-hostname>.local.
  • After making the changes, flush the DNS cache using sudo dscacheutil -flushcache and restart mDNSResponder with sudo killall -HUP mDNSResponder.
  • Verify that the fix worked by launching Codex CLI and checking for the startup delay.

Example

# Add local hostname to /etc/hosts
echo "127.0.0.1 $(hostname).local" | sudo tee -a /etc/hosts
echo "::1 $(hostname).local" | sudo tee -a /etc/hosts

# Flush DNS cache and restart mDNSResponder
sudo dscacheutil -flushcache
sudo killall -HUP mDNSResponder

Notes

This workaround may not be applicable if the issue is caused by a different factor, and further investigation may be necessary to determine the root cause.

Recommendation

Apply the workaround by adding the local hostname to /etc/hosts and flushing the DNS cache, as it has been reported to resolve the startup delay issue.

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

codex - 💡(How to fix) Fix codex takes ~5 seconds before entering the TUI [1 comments, 2 participants]