codex icon indicating copy to clipboard operation
codex copied to clipboard

`codex login` failed

Open MeowShe opened this issue 1 year ago β€’ 21 comments

What version of Codex is running?

codex-cli (rust) all versions

Which model were you using?

No response

What platform is your computer?

Darwin 24.5.0 arm64 arm

What steps can reproduce the bug?

codex login, then while call the callback URL after completing OpenAI's auth.

What is the expected behavior?

No response

What do you see instead?

In terminal:

Starting local login server on http://localhost:1455
If your browser did not open, navigate to this URL to authenticate:

https://auth.openai.com/oauth/authorize?response_type=...
Error logging in: login_with_chatgpt subprocess failed: 

In browser: Error code 500. Message: Token exchange failed: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1000)>.

Additional information

  • Tried rm -rf ~/.codex.
  • Use OPENAI_API_KEY instead of paid ChatGPT login works fine.
  • Using http & https proxy.

MeowShe avatar Jul 02 '25 09:07 MeowShe

I was able to reproduce the issue described. Unable to find any solution at the current time.

matt-novoselov avatar Jul 02 '25 12:07 matt-novoselov

Same for me #1452

SuperstrongBE avatar Jul 02 '25 21:07 SuperstrongBE

@MeowShe Try the NPM version instead of homebrew, Working for me #1099

SuperstrongBE avatar Jul 02 '25 21:07 SuperstrongBE

@MeowShe Try the NPM version instead of homebrew, Working for me #1099

Thank you, @SuperstrongBE. I can confirm that the issue is present in Homebrew version, but not in the NPM one.

Image

matt-novoselov avatar Jul 02 '25 21:07 matt-novoselov

@SuperstrongBE @matt-novoselov Yes, the npm package works, but its latest tagged version is 0.1.2505172129, not 0.2.0; this seems to be a new issue introduced by the Rust version

MeowShe avatar Jul 02 '25 22:07 MeowShe

Yes just realized that 😭

SuperstrongBE avatar Jul 02 '25 22:07 SuperstrongBE

I have same error but on ssl.c:1018 not 1000

Error response
Error code: 500

Message: Token exchange failed: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1018)>.

Error code explanation: 500 - Server got itself in trouble.

Using brew or npm did not solve the issue.

hamza-cskn avatar Jul 11 '25 06:07 hamza-cskn

I have same error but on ssl.c:1018 not 1000

Error response
Error code: 500

Message: Token exchange failed: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1018)>.

Error code explanation: 500 - Server got itself in trouble.

Using brew or npm did not solve the issue.

Maybe it's because you're using 0.3.0?

MeowShe avatar Jul 11 '25 09:07 MeowShe

I have same error but on ssl.c:1018 not 1000

Error response
Error code: 500

Message: Token exchange failed: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1018)>.

Error code explanation: 500 - Server got itself in trouble.

Using brew or npm did not solve the issue.

Maybe it's because you're using 0.3.0?

I use 0.6.0 currently

hamza-cskn avatar Jul 13 '25 11:07 hamza-cskn

Still happening in version 0.8.0 in both brew and npm versions for me (I tried installing it both ways)

Exact same error as the above.

lbacaj avatar Jul 22 '25 16:07 lbacaj

These commands solved it for me: export SSL_CERT_FILE=$(python3 -m certifi) export REQUESTS_CA_BUNDLE=$(python3 -m certifi)

Then try "codex login" one more time

thelonglincoln avatar Jul 23 '25 09:07 thelonglincoln

@thelonglincoln

Thx a ton, that helped! Still waiting for my "organization" authorization to come in (takes up to 15min, their errormessage says...)

beat-murmann avatar Jul 23 '25 10:07 beat-murmann

It happens because of outdated python certs, you have to update the list of known CAs.

For me this worked

/Applications/Python\ 3.11/Install\ Certificates.command

Make sure you update with your python path and version.

ChatGPT Summary

βœ… Fix for codex login failing with SSL certificate verify error on macOS

If you're on macOS and get this error during codex login:

Token exchange failed: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1000)>

πŸ‘‰ It’s likely caused by missing CA certificates in your Python environment.

βœ… Solution (macOS, Python installed from python.org):

Run this in Terminal:

open /Applications/Python\ 3.11/Install\ Certificates.command

This installs the required root certificates that Python uses for SSL.

After that, codex login should work without SSL errors.

alpha-adam avatar Jul 23 '25 16:07 alpha-adam

So now, we have confirmed that this is an issue caused by SSL certificate verification in Python.

MeowShe avatar Jul 24 '25 03:07 MeowShe

@MeowShe did it resolve your issue?

alpha-adam avatar Jul 24 '25 06:07 alpha-adam

I also executed codex login after installation of npm version and got this result:

konard@MacBook-Pro-Konstantin ~ % codex --version
codex-cli 0.10.0
Image
http://localhost:1455/auth/callback?code=ac_GLaE3_cutkkyvb68UUZTOzlGanG_kZ8TfqUMJpdFe-c.e1290Qt-Nnd6V2o_SAJndzY3lt3ZZryo3E_njMIAP-o&scope=openid+profile+email+offline_access&state=909a9182a757654a482d1dbbd009ecff9ae79e70b6ab072157835e6a9279b008
Error response

Error code: 500

Message: Token exchange failed: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1000)>.

Error code explanation: 500 - Server got itself in trouble.

konard avatar Jul 28 '25 12:07 konard

@MeowShe did it resolve your issue?

Yes, it works.

And I noticed that this is explicitly mentioned as something to do in the Python Installer but I never do it before haha

# install_certifi.py
#
# sample script to install or update a set of default Root Certificates
# for the ssl module.  Uses the certificates provided by the certifi package:
#       https://pypi.org/project/certifi/

import os
import os.path
import ssl
import stat
import subprocess
import sys

STAT_0o775 = ( stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR
             | stat.S_IRGRP | stat.S_IWGRP | stat.S_IXGRP
             | stat.S_IROTH |                stat.S_IXOTH )

def main():
    openssl_dir, openssl_cafile = os.path.split(
        ssl.get_default_verify_paths().openssl_cafile)

    print(" -- pip install --upgrade certifi")
    subprocess.check_call([sys.executable,
        "-E", "-s", "-m", "pip", "install", "--upgrade", "certifi"])

    import certifi

    # change working directory to the default SSL directory
    os.chdir(openssl_dir)
    relpath_to_certifi_cafile = os.path.relpath(certifi.where())
    print(" -- removing any existing file or link")
    try:
        os.remove(openssl_cafile)
    except FileNotFoundError:
        pass
    print(" -- creating symlink to certifi certificate bundle")
    os.symlink(relpath_to_certifi_cafile, openssl_cafile)
    print(" -- setting permissions")
    os.chmod(openssl_cafile, STAT_0o775)
    print(" -- update complete")

if __name__ == '__main__':
    main()

MeowShe avatar Jul 29 '25 09:07 MeowShe

export SSL_CERT_FILE=$(python3 -m certifi) export REQUESTS_CA_BUNDLE=$(python3 -m certifi)

Thank you, it works for me.

Doublefire-Chen avatar Aug 01 '25 11:08 Doublefire-Chen

πŸ‘‰ It’s likely caused by missing CA certificates in your Python environment.

βœ… Solution (macOS, Python installed from python.org):

Run this in Terminal:

open /Applications/Python\ 3.11/Install\ Certificates.command

This installs the required root certificates that Python uses for SSL.

After that, codex login should work without SSL errors.

This worked perfectly for me here. Thanks @alpha-adam Context - Installed via brew - Python 3.11.6

schwarztim avatar Aug 01 '25 17:08 schwarztim

Fixed in 0.22.0. #2044

MeowShe avatar Aug 17 '25 01:08 MeowShe