`codex login` failed

Resolved 💬 21 comments Opened Jul 2, 2025 by MeowShe Closed Aug 17, 2025

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.

View original on GitHub ↗

21 Comments

matt-novoselov · 1 year ago

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

SuperstrongBE · 1 year ago

Same for me
#1452

SuperstrongBE · 1 year ago

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

matt-novoselov · 1 year ago
@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.

<img width="430" alt="Image" src="https://github.com/user-attachments/assets/cca0475c-1434-42f7-b30c-687bcfe1938d" />

MeowShe · 1 year ago

@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

SuperstrongBE · 1 year ago

Yes just realized that 😭

hamza-cskn · 1 year ago

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.

MeowShe · 1 year ago
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?

hamza-cskn · 1 year ago
> 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

lbacaj · 12 months ago

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.

thelonglincoln · 12 months ago

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

beat-murmann · 12 months ago

@thelonglincoln

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

alpha-adam · 12 months ago

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.

MeowShe · 12 months ago

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

alpha-adam · 12 months ago

@MeowShe did it resolve your issue?

konard · 11 months ago

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

<img width="1277" height="570" alt="Image" src="https://github.com/user-attachments/assets/1dced33e-d27f-470c-8793-8e1ca220ee9a" />

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.
MeowShe · 11 months ago
@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()
Doublefire-Chen · 11 months ago
export SSL_CERT_FILE=$(python3 -m certifi) export REQUESTS_CA_BUNDLE=$(python3 -m certifi)

Thank you, it works for me.

schwarztim · 11 months ago
👉 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

MeowShe · 11 months ago

Fixed in 0.22.0. #2044

MDsniper · 10 months ago

This actually worked for me as I connect to a remote server in my home lab, and I think this will work for most people. Connect remotely using this and then log into Codex and then go through the process. And when you copy the URL to your web page and authenticate, it'll work perfectly.

ssh -L 1455:localhost:1455 [username]@[remote-lab-server]