Contents
- 1. Prerequisites & Terminal Network Configuration
- Terminal Proxy Setup (Crucial for CLI)
- Method A: Desktop App (Recommended for Beginners)
- Method B: Terminal CLI (Recommended for Engineers)
- 2. Authentication & OAuth Sign-in
- 3. Verification & First Ping
- 4. The 3 Sanity Checkpoints
- 5. Troubleshooting & Edge Cases
- 6. Best Practice: Protect Your Codebase from Day One

Among modern AI programming assistants, OpenAI's Codex stands out for its strong architectural reasoning and autonomous engineering capabilities, whether packaged as a standalone desktop application or running inside your terminal as a CLI.
However, newcomers often hit roadblocks early in the setup process. Complex prerequisites, connection timeouts, or missing environment variables can cause frustration before writing a single line of code.
In reality, running Codex successfully comes down to three fundamental actions: installing the binary, authenticating your account, and verifying bidirectional communication.

This guide covers both the Desktop and CLI workflows, along with practical troubleshooting steps and essential terminal configuration.
1. Prerequisites & Terminal Network Configuration
Before initiating installation, ensure your environment can reliably reach chatgpt.com.
Terminal Proxy Setup (Crucial for CLI)
A frequent pitfall for developers in restricted network environments is that terminal sessions do not automatically inherit system-level graphical proxy configurations.
If your browser can access ChatGPT but your terminal installation script hangs, explicitly route traffic through your local proxy port (e.g., standard Clash/v2ray port 7890):
macOS / Linux:
export http_proxy="http://127.0.0.1:7890"
export https_proxy="http://127.0.0.1:7890"
export all_proxy="socks5://127.0.0.1:7890"
# Verify connectivity
curl -I https://chatgpt.com/codex
Windows PowerShell:
$env:HTTP_PROXY="http://127.0.0.1:7890"
$env:HTTPS_PROXY="http://127.0.0.1:7890"
A returned HTTP 200 or 301 status confirms that the terminal tunnel is active.
Method A: Desktop App (Recommended for Beginners)
If you prefer a clean graphical user interface without managing shell environments:
- Navigate to the official download page:
https://chatgpt.com/codex; - Download the installer for your operating system (macOS
.dmgor Windows.exe); - Double-click the installer and follow the on-screen prompts.
The desktop app mirrors familiar messaging interfaces, offering an accessible starting point.
Method B: Terminal CLI (Recommended for Engineers)
For developers who spend most of their time in Neovim, Tmux, or integrated VS Code terminals, the CLI provides tighter file system integration and faster iteration.
macOS & Linux: Run the official automated shell script:
curl -fsSL https://chatgpt.com/codex/install.sh | sh
Windows:
Launch PowerShell as Administrator (do not use legacy cmd.exe) and run:
powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"
Once installation finishes, restart your terminal session to ensure your environment reloads the updated $PATH.
2. Authentication & OAuth Sign-in
Once installed, link your OpenAI account:
Desktop App: Launch the app and click "Sign In." Your default browser will open automatically. Complete authentication and click Authorize.
Terminal CLI: Execute the startup command:
codexCodex spins up a temporary local callback server and opens the browser authorization portal. Once you approve access on the web page, the terminal captures the authentication token and prints
Authentication successful.
3. Verification & First Ping
To ensure the end-to-end toolchain is sound, avoid asking Codex to refactor an entire codebase immediately. Instead, run a minimal ping test.
Desktop App: In the bottom message input, simply type:
Hello
Terminal CLI: Do not launch the CLI directly inside a mission-critical project repository during initial testing. Create an isolated sandbox directory first:
mkdir codex-test
cd codex-test
codex
Inside the interactive prompt, type:
Hello
If the model streams back a coherent greeting, your local binary runtime, network proxy route, OAuth authorization, and API streaming pipeline are all functioning properly.
4. The 3 Sanity Checkpoints
Keep these criteria in mind when diagnosing setup issues:
- Installed: The desktop icon opens, or executing
codex --versionin terminal outputs valid version information. - Authenticated: The browser confirms login and the terminal releases its authorization listener.
- Responsive: Sending a simple greeting returns a real-time streaming completion.
5. Troubleshooting & Edge Cases
command not found: codex: Your shell has not refreshed its path cache. Restart the terminal or check whether~/.local/bin(or similar install paths) exists in yourPATHconfiguration.- Windows
irm is not recognized: You are running the legacy Command Prompt (cmd.exe). Switch to Windows PowerShell. - Infinite Loading on Login Page:
Confirm that your proxy allows local loopback traffic (
127.0.0.1), as the OAuth flow requires the browser to pass the token back to a local port. - Install Script Stalls at 0%: Terminal traffic is being blocked. Revisit Section 1 to export your HTTP proxy settings.
6. Best Practice: Protect Your Codebase from Day One
When introducing Codex to an existing repository, start with a read-only exploration prompt before authorizing file modifications:
Review the project structure and dependencies in package.json.
Provide a high-level summary of what this application does and outline its core modules.
Do NOT modify, create, or delete any files during this step.
Allowing the agent to describe its mental model first helps verify its context before making real code edits, avoiding unexpected repository churn.