Skip to content

OAuth error: fetch failed #40

Closed
Closed

Description

@egarl004

When attempting to authenticate, "fetch failed" error is presented after authenticating via web browser. Sign in methods did not yield different results.

Image

Activity

  1. egarl004 commented on Feb 24, 2025

    @egarl004
    Author

    node version - v22.11.0
    npm version - 10.9.0
    Mac - 15.3.1 (24D70)

  2. seanxwzhang commented on Feb 25, 2025

    @seanxwzhang

    Encountered the same thing, tried both chrome and edge, failed with "OAuth error: fetch failed"

    ➜  ~ npm --version
    10.9.2
    ➜  ~ node --version
    v23.6.0
    ➜  ~ sw_vers
    ProductName:		macOS
    ProductVersion:		15.3
    BuildVersion:		24D60
    ➜  ~ claude --version
    0.2.9
    
  3. monsterooo commented on Feb 26, 2025

    @monsterooo

    I was in the same situation

  4. MayBAMemory commented on Feb 26, 2025

    @MayBAMemory

    same

  5. hadi-sg commented on Feb 26, 2025

    @hadi-sg

    I was having the same issue but resolved when removing vpn connection. Worth a try if you're behind corporate vpn/firewall as well.

  6. adaratech commented on Feb 26, 2025

    @adaratech

    same issue... anyone solved this?

  7. liaofeng commented on Feb 26, 2025

    @liaofeng

    same issue

  8. Krushang-Shah commented on Feb 26, 2025

    @Krushang-Shah

    same issue

  9. egarl004 commented on Feb 26, 2025

    @egarl004
    Author

    I was having the same issue but resolved when removing vpn connection. Worth a try if you're behind corporate vpn/firewall as well.

    I did suspect this, disabled vpn and still had the same issue though on my end.

  10. sebastiangeiger01 commented on Feb 26, 2025

    @sebastiangeiger01

    This is probably due to the ssl certificate chain being broken by zscaler/other SaaS solution used in company networks. Experiencing the same issue...

  11. moob123 commented on Feb 26, 2025

    @moob123

    I am having this same issue with a vanilla internet connection, no vpn, macos, zshell, nvm, v16.14.0, tried both chrome and safari as default browsers. sometimes i get to a key that i can copy in the browser but the shell script will not accept it, shell and browser process seems not to be in phase, just dancing around.

  12. FoRJu commented on Feb 26, 2025

    @FoRJu

    I am expereincing the same issue above.

    Wondering if this is something Claude Code can fix...

  13. FoRJu commented on Feb 26, 2025

    @FoRJu

    this is fixed with ChatGPT with terminal. Update node and npm to latest version. All fine.

    npm --version
    10.9.2
    node --version
    v23.9.0

  14. sjsage522 commented on Feb 26, 2025

    @sjsage522

    os : Ubuntu 22.04 LTS
    node -v : v20.18.0
    npm -v : 10.8.2

  15. moob123 commented on Feb 27, 2025

    @moob123

    In my case - with nvm - the issue was a lingering prefix in .npmrc pointing to an older version of node. Now clearing this, with node version
    node -v
    v20.11.0
    it works fine.

  16. shevit commented on Feb 27, 2025

    @shevit

    Step 1: Test what's wrong

    Run 'node' then execute

    > fetch("https://www.google.com/")
    

    If you see an error, it means that Claude Code has the same problem accessing internet.

    Step 2 : Fix:

    In my case it was a ZScaler certificate

    You need to configure Node.js to trust the Zscaler certificate.

    Option 1: set the NODE_TLS_REJECT_UNAUTHORIZED environment variable (quick but insecure)

    export NODE_TLS_REJECT_UNAUTHORIZED=0

    Option 2: Add the Zscaler certificate to Node.js (recommended )

    First, download/export the Zscaler root certificate:

    • Open any HTTPS website in your browser
    • Click on the padlock icon in the address bar
    • View the certificate details
    • Export/save the Zscaler root CA certificate (usually named "ZscalerRootCertificate" or similar)

    add the certificate to Node.js:

    mkdir -p ~/.node-certs
    
    # Copy your Zscaler certificate there
    cp /path/to/ZscalerRootCertificate.pem ~/.node-certs/
    
    # Set the NODE_EXTRA_CA_CERTS environment variable
    export NODE_EXTRA_CA_CERTS=~/.node-certs/ZscalerRootCertificate.pem

    Add the environment variable to your shell profile for persistence:

    bashCopyecho 'export NODE_EXTRA_CA_CERTS=~/.node-certs/ZscalerRootCertificate.pem' >> ~/.bashrc
    # Or if using Zsh
    echo 'export NODE_EXTRA_CA_CERTS=~/.node-certs/ZscalerRootCertificate.pem' >> ~/.zshrc
  17. ArthurClune commented on Feb 27, 2025

    @ArthurClune

    Thanks to @shevit !

    For those not behind a VPN device but getting the same error, the safe fix is to tell node where your certificates are. On macOS

    $ export NODE_EXTRA_CA_CERTS=/etc/ssl/cert.pem
    $ claude

    and things should work.

  18. egarl004 commented on Feb 27, 2025

    @egarl004
    Author

    thanks @shevit! worked perfectly.

  19. kurosato commented on Feb 27, 2025

    @kurosato

    Thanks @shevit ! The fetch showed that npm was defaulting to IPV6 usage (Ubuntu server 24.04), after changing the NODE_OPTIONS as below, this solved the issue.

    Linux/macOS

    export NODE_OPTIONS="--dns-result-order=ipv4first"

    Windows Command Prompt

    set NODE_OPTIONS=--dns-result-order=ipv4first

    Windows PowerShell

    $env:NODE_OPTIONS="--dns-result-order=ipv4first"

  20. PitzTech commented on May 25, 2025

    @PitzTech

    Thanks @kurosato!!
    export NODE_OPTIONS="--dns-result-order=ipv4first" worked for me on WSL

    Distributor ID: Ubuntu
    Description: Ubuntu 22.04.5 LTS
    Release: 22.04

  21. github-actions commented on Aug 9, 2025

    @github-actions

    This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.

  22. locked as resolved and limited conversation to collaborators on Aug 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions