How do I log in to Codex CLI when the browser won't open?

If the browser won't open when you log in to Codex CLI, don't reinstall it just yet. When running locally, start by checking the default browser. When connecting to a remote Mac over SSH, first establish which computer is opening the browser. If your version and account support it, run codex login --device-auth, enter the code from that login attempt in a browser on your own computer, then verify the result with codex login status.

First, check which computer is running the login command

If you're sitting at a Mac and running the login command in its terminal, the CLI and browser are usually on the same computer. If the browser doesn't launch, copy the complete authorization URL shown in the terminal and paste it into your browser manually. Don't construct the URL yourself or remove any query parameters.

If you're connecting to a Mac from Windows over SSH, the situation is different: the CLI runs on the remote machine, while the browser in front of you runs on Windows. Standard browser-based login may rely on a local callback. In the URL, localhost refers to the computer opening that URL, not automatically to the machine at the other end of the SSH connection.

“The page won't open” and “the page says it worked, but the terminal is still waiting” may therefore have different causes. Note where the command is running, where the browser is running, and any terminal errors before choosing a login method.

The login page, device code, and waiting terminal process must all belong to the same login attempt. Don't start several login processes and then authorize whichever browser tab happens to be open.

Check the version, then use device-code login

In the terminal where Codex CLI actually runs, check the version and available options first:

codex --version
codex login --help

If the help output lists --device-auth, run:

codex login --device-auth

Leave this terminal process running. In a browser on your own computer, open the address provided in the terminal, enter the device code, and confirm which account you're authorizing. Once you've finished, return to the terminal and wait for the result, then check:

codex login status

Device codes expire; use the validity period shown in the current output. If a code expires, cancel the original process and start again. Don't keep submitting the old code or mix steps from old and new login attempts.

If you get an unknown-option error, first check which executable is being invoked:

command -v codex
type -a codex

If you have installations in multiple locations, updating one doesn't mean your current terminal is using it. Update through the original installation method and check the help output again, rather than adding more installations on top. Your account or organization may also restrict device-code login, so check the current login page's messages and your administrator's settings.

If the terminal keeps waiting after authorization, troubleshoot by symptom

Start with the terminal output. Don't assume every failure is a network issue.

Device-code authorization still requires the remote CLI to reach the authentication service. A working browser connection alone doesn't guarantee success. After a failure, record the error type, CLI version, and the step where it occurred. Remove device codes, tokens, and complete authorization URLs before sharing logs.

Verify the account, and keep quota issues separate from login issues

codex login status checks the authentication state in the current terminal. A success message in the browser is not a substitute for this check. Afterward, launch Codex once as well to confirm that it doesn't ask you to log in again.

If you're signed in to the wrong account, log out and authorize again:

codex logout
codex login --device-auth
codex login status

Before logging in again, make sure the intended account is selected in the browser. If an API Key has been configured in the environment, also check which authentication method is currently in use. A subscription login and API billing should not be treated as sharing the same quota.

If you see an insufficient-quota, unavailable-model, or organization-permission message after logging in successfully, address that specific error. Repeatedly logging out and back in generally won't increase your quota or change your account permissions.

Why run it on a Mac, and how do you log out afterward?

Codex CLI isn't limited to macOS. It's the work you need to do afterward that may require a Mac—for example, invoking the Xcode toolchain, running macOS tests, or checking an Apple-platform project. The browser handles authorization, while the Mac executes commands; they don't have to be on the same computer.

If you only have Windows but your project requires macOS, you can rent a dedicated Mac by the day from VPSVNC and work over SSH. Check the console for the configurations currently available. Remote operation still depends on a stable network connection and does not bypass the tool's account or permission requirements.

On a shared or short-term machine, use a separate macOS user account where possible rather than sharing the same CLI credentials with others. When you're done, run codex logout, then codex login status to confirm that you've logged out. If credentials may have been exposed, revoke the relevant authorization in your account's security settings as well. Simply closing the terminal does not log you out.

Frequently asked questions

Does an SSH login require a browser on the remote Mac?

Not necessarily. If your version and account support device-code authentication, run codex login --device-auth and approve it in a browser on your own computer. Use the address and code printed by that login attempt.

Why is the terminal still waiting after browser approval?

The approval may belong to an older attempt, or a callback may have reached the wrong computer. Cancel the old attempt, start a fresh login, then run codex login status to verify the CLI session.

Rent a cloud Mac for your project

Dedicated Mac mini M4 with 16GB RAM and 256GB SSD, from $22.4/day. Ready on the day you order. Requires a stable internet connection. The instance stops when your rental expires if you don't renew; no automatic charges. Back up your files before your rental ends.

Rent a cloud Mac by the day

Test your project workflow for one day

Dedicated Mac mini M4, from $22.4/day. Ready on the day you order. The instance stops when your rental expires if you don't renew; no automatic charges.