Skip to content

cargo upgrade returns 401 consistently even after changing registry token #931

Open

Description

@shrasrir
% cargo upgrade                            
    Checking virtual workspace's dependencies
Error: status code '401 Unauthorized': the request was not authorized

cargo upgrade --verbose dont seem to give any extra details on the error.

Tried the following:

  1. removing all cache
  2. renewing the token in config.toml
  3. cargo search --registry internal-registry-name internal-feature works fine with the token enabled
  4. other cargo commands like cargo clean, cargo build, cargo test all work fine

This was working fine for many months and seeing this issue only the last couple months now.

Activity

  1. epage commented on May 1, 2025

    @epage
    Collaborator

    0.13.2 fixed a bug where we were silencing network errors. Do you think that you had upgraded to that version within that time window?

  2. shrasrir commented on May 1, 2025

    @shrasrir
    Author

    yes, have been using version > 1.84 the last few months. I upgraded it to v1.86.0 and tried running cargo upgrade but keep getting 401 consistently.

  3. epage commented on May 1, 2025

    @epage
    Collaborator

    Note that cargo-edits version is mostly independent of what version of Cargo you are using.

  4. shrasrir commented on May 1, 2025

    @shrasrir
    Author

    oh ok, yes I see cargo-edit-upgrade 0.13.2

  5. shrasrir commented on May 1, 2025

    @shrasrir
    Author

    Seeing this issue only on updating cargo-edit to versions 0.13.2 or 0.13.3. Looks like 0.13.1 is the last version that doesn't see this error fyi.

  6. anton-dutov commented on Jun 13, 2025

    @anton-dutov

    @epage
    After updating cargo edit to latest version, an authorization error appeared, after rolling back to 0.13.1, it works again
    The error appears when using a private registry with token auth (credentials.toml)

    @shrasrir Thanks, after reverting version to 0.13.1 issue is gone

  7. pseyfert-sevensense commented on Jun 23, 2025

    @pseyfert-sevensense

    chiming in:

    with version 0.13.1 I get no errors BUT the private registry doesn't seem to get checked for upgrades

    pseyfert@catuai:~/SOMEPATH > cargo upgrade --version
    cargo-edit-upgrade 0.13.1
    pseyfert@catuai:~/SOMEPATH > cargo upgrade -vvvv
        Checking REDACTED's dependencies
    name                             old req compatible latest  new req note
    ====                             ======= ========== ======  ======= ====
    anyhow                           1       1.0.98     1.0.98  1
    clap                             3.0     3.2.25     4.5.40  3.2     incompatible
    flate2                           1.0     1.1.2      1.1.2   1.1
    log                              0.4     0.4.27     0.4.27  0.4
    once_cell                        1.14    1.21.3     1.21.3  1.21
    serde                            1.0     1.0.219    1.0.219 1.0
    serde_yaml                       0.8     0.8.26     0.9.34  0.8     incompatible
    REDACTED REDACTED REDACTED       10.9.5  -          -       10.9.5
    REDACTED REDACTED REDACTED       10.9.5  -          -       10.9.5
    REDACTED REDACTED REDACTED       10.9.5  -          -       10.9.5
    REDACTED REDACTED REDACTED       10.9.5  -          -       10.9.5
    REDACTED REDACTED REDACTED       10.9.5  -          -       10.9.5
    REDACTED REDACTED REDACTED       6.7.0   -          -       6.7.0
    REDACTED REDACTED REDACTED       6.7.0   -          -       6.7.0
    stderrlog                        0.4     0.4.3      0.6.0   0.4     incompatible
    tar                              0.4     0.4.44     0.4.44  0.4
    tempfile                         3.5.0   3.20.0     3.20.0  3.20.0
    sha256                           1.5.0   1.6.0      1.6.0   1.6.0
    REDACTED REDACTED REDACTED       3       -          -       3
    REDACTED REDACTED REDACTED       3       -          -       3
       Upgrading recursive dependencies   
         Locking 36 packages to latest compatible versions
        Updating addr2line v0.22.0 -> v0.24.2            
        Removing adler v1.0.2
        Updating async-trait v0.1.80 -> v0.1.88                                                                                                                    
        Updating autocfg v1.1.0 -> v1.5.0
        Updating backtrace v0.3.73 -> v0.3.75                                                                                                                     
        Updating bitflags v2.4.2 -> v2.9.1                         
    ...                                 
    

    with newer versions, I get asked for authentication but then get the 401 errors

    pseyfert@catuai:~/SOMEPATH > cargo upgrade --version                                        
    cargo-edit-upgrade 0.13.6                                  
    pseyfert@catuai:~/SOMEPATH > cargo upgrade -vvvv                     
    Enter the password for Paul.Seyfert@sevensense.ch at REDACTED:                               
        Checking REDACTED's dependencies                                                           
    [2025-06-23T10:15:39Z TRACE cargo_edit::index] opening index entry for sparse+https://index.crates.io/
    [2025-06-23T10:15:39Z TRACE reqwest::blocking::wait] (ThreadId(1)) park without timeout
    [2025-06-23T10:15:39Z TRACE reqwest::blocking::client] (ThreadId(2)) start runtime::block_on
    [2025-06-23T10:15:39Z TRACE cargo_edit::index] krate anyhow                                
    [2025-06-23T10:15:39Z TRACE reqwest::blocking::wait] wait at most 30s
    [2025-06-23T10:15:39Z TRACE reqwest::blocking::wait] (ThreadId(1)) park timeout 29.999999509s
    [2025-06-23T10:15:39Z DEBUG reqwest::connect] starting new connection: https://index.crates.io/
    [2025-06-23T10:15:39Z TRACE reqwest::blocking::wait] wait at most 30s                       
    [2025-06-23T10:15:39Z TRACE cargo_edit::index] krate clap            
    [2025-06-23T10:15:39Z TRACE reqwest::blocking::wait] wait at most 30s
    [2025-06-23T10:15:39Z TRACE reqwest::blocking::wait] (ThreadId(1)) park timeout 29.9999998s
    [2025-06-23T10:15:39Z TRACE reqwest::blocking::wait] wait at most 30s                       
    [2025-06-23T10:15:39Z TRACE cargo_edit::index] krate flate2          
    [2025-06-23T10:15:39Z TRACE reqwest::blocking::wait] wait at most 30s
    [2025-06-23T10:15:39Z TRACE reqwest::blocking::wait] (ThreadId(1)) park timeout 29.99999985s
    [2025-06-23T10:15:39Z TRACE reqwest::blocking::wait] wait at most 30s                       
    [2025-06-23T10:15:39Z TRACE cargo_edit::index] krate log             
    [2025-06-23T10:15:39Z TRACE reqwest::blocking::wait] wait at most 30s
    [2025-06-23T10:15:39Z TRACE reqwest::blocking::wait] (ThreadId(1)) park timeout 29.99999992s
    [2025-06-23T10:15:39Z TRACE reqwest::blocking::wait] wait at most 30s                       
    [2025-06-23T10:15:39Z TRACE cargo_edit::index] krate once_cell       
    [2025-06-23T10:15:39Z TRACE reqwest::blocking::wait] wait at most 30s
    [2025-06-23T10:15:39Z TRACE reqwest::blocking::wait] (ThreadId(1)) park timeout 29.99999993s
    [2025-06-23T10:15:39Z TRACE reqwest::blocking::wait] wait at most 30s                       
    [2025-06-23T10:15:39Z TRACE cargo_edit::index] krate serde           
    [2025-06-23T10:15:39Z TRACE reqwest::blocking::wait] wait at most 30s                                                 
    [2025-06-23T10:15:39Z TRACE reqwest::blocking::wait] (ThreadId(1)) park timeout 29.99999995s
    [2025-06-23T10:15:39Z TRACE reqwest::blocking::wait] wait at most 30s                       
    [2025-06-23T10:15:39Z TRACE cargo_edit::index] krate serde_yaml
    [2025-06-23T10:15:39Z TRACE reqwest::blocking::wait] wait at most 30s
    [2025-06-23T10:15:39Z TRACE reqwest::blocking::wait] (ThreadId(1)) park timeout 29.99999991s 
    [2025-06-23T10:15:39Z TRACE reqwest::blocking::wait] wait at most 30s                          
    [2025-06-23T10:15:39Z TRACE cargo_edit::index] opening index entry for sparse+https://crates.REDACTED/REDACTED/crates/
    [2025-06-23T10:15:39Z TRACE reqwest::blocking::wait] (ThreadId(1)) park without timeout
    [2025-06-23T10:15:39Z TRACE reqwest::blocking::client] (ThreadId(4)) start runtime::block_on
    [2025-06-23T10:15:39Z TRACE cargo_edit::index] krate REDACTED
    [2025-06-23T10:15:39Z TRACE reqwest::blocking::wait] wait at most 30s
    [2025-06-23T10:15:39Z TRACE reqwest::blocking::wait] (ThreadId(1)) park timeout 29.999999679s
    [2025-06-23T10:15:39Z DEBUG reqwest::connect] starting new connection: https://crates.REDACTED/
    [2025-06-23T10:15:39Z TRACE reqwest::blocking::wait] wait at most 30s
    [2025-06-23T10:15:39Z TRACE reqwest::blocking::client] closing runtime thread (ThreadId(4))
    [2025-06-23T10:15:39Z TRACE reqwest::blocking::client] signaled close for runtime thread (ThreadId(4))
    [2025-06-23T10:15:39Z TRACE reqwest::blocking::client] (ThreadId(4)) Receiver is shutdown
    [2025-06-23T10:15:39Z TRACE reqwest::blocking::client] (ThreadId(4)) end runtime::block_on
    [2025-06-23T10:15:39Z TRACE reqwest::blocking::client] (ThreadId(4)) finished
    [2025-06-23T10:15:39Z TRACE reqwest::blocking::client] closed runtime thread (ThreadId(4))
    [2025-06-23T10:15:39Z TRACE reqwest::blocking::client] closing runtime thread (ThreadId(2))
    [2025-06-23T10:15:39Z TRACE reqwest::blocking::client] signaled close for runtime thread (ThreadId(2))
    [2025-06-23T10:15:39Z TRACE reqwest::blocking::client] (ThreadId(2)) Receiver is shutdown
    [2025-06-23T10:15:39Z TRACE reqwest::blocking::client] (ThreadId(2)) end runtime::block_on
    [2025-06-23T10:15:39Z TRACE reqwest::blocking::client] (ThreadId(2)) finished
    [2025-06-23T10:15:39Z TRACE reqwest::blocking::client] closed runtime thread (ThreadId(2))
    Error: status code '401 Unauthorized': the request was not authorized
    

    afaiu, the authentication is successful: I ran rm -rf ~/.cargo/registry before cargo upgrade, and the cargo upgrade command re-populated ~/.cargo/registry/{cache,src}/crates-REDACTED-HASH/

    TL;DR:
    reverting to 0.13.1 makes the 401 errors go away and cargo upgrade exists successfully (return code 0) BUT it doesn't actually upgrade dependencies for me.

  8. MaxG87 commented on Nov 10, 2025

    @MaxG87

    I just wanted to report that I am still affected by this bug. I receive my cargo-edit through Arch's package repository.

     ~$ pacman -Qi cargo-edit
    Installed From  : cachyos-extra-v3
    Name            : cargo-edit
    Version         : 0.13.7-1.1
    Description     : Managing cargo dependencies from the command line
    Architecture    : x86_64_v3
    URL             : https://github.com/killercup/cargo-edit/releases
    Licenses        : MIT  Apache-2.0
    Groups          : None
    Provides        : None
    Depends On      : cargo  libssh2  openssl
    Optional Deps   : None
    Required By     : None
    Optional For    : None
    Conflicts With  : None
    Replaces        : None
    Installed Size  : 7,36 MiB
    Packager        : CachyOS <admin@cachyos.org>
    Build Date      : Fr 08 Aug 2025 23:06:10 CEST
    Install Date    : Mo 10 Nov 2025 12:49:49 CET
    Install Reason  : Explicitly installed
    Install Script  : No
    Validated By    : Signature
    

    This leaves me unable to upgrade any dependencies using cargo upgrade, since I depend on one crate from a private registry.

  9. azeater commented on Apr 14, 2026

    @azeater

    Just wanted to bump this - I'm also seeing authentication issues when trying to run cargo upgrade with a private registry. All other cargo commands work fine (e.g. update, search etc). My version is 0.13.9.

  10. r0wdiggity commented on May 14, 2026

    @r0wdiggity
    Run cargo upgrade -i --pinned -vvvv 2>&1
      cargo upgrade -i --pinned -vvvv 2>&1
      shell: /usr/bin/bash -e {0}
      env:
        CARGO_HOME: /home/runner/.cargo
        CARGO_INCREMENTAL: 0
        CARGO_TERM_COLOR: always
        AWS_DEFAULT_REGION: ***
        AWS_REGION: ***
        AWS_ACCESS_KEY_ID: ***
        AWS_SECRET_ACCESS_KEY: ***
        AWS_SESSION_TOKEN: ***
        CARGO_LOG: cargo::sources=debug,cargo::ops=debug
        RUST_LOG: debug
        Checking reporting-lib's dependencies
    [2026-05-14T18:05:04Z TRACE cargo_edit::index] opening index entry for sparse+[https://<redacted.d.codeartifact.***.amazonaws.com/cargo/](https://<redacted>d.codeartifact.%2A%2A%2A.amazonaws.com/cargo)
    [2026-05-14T18:05:04Z TRACE reqwest::blocking::wait] (ThreadId(1)) park without timeout
    [2026-05-14T18:05:04Z TRACE reqwest::blocking::client] (ThreadId(2)) start runtime::block_on
    [2026-05-14T18:05:04Z TRACE cargo_edit::index] krate anyhow
    [2026-05-14T18:05:04Z TRACE reqwest::blocking::wait] wait at most 30s
    [2026-05-14T18:05:04Z TRACE reqwest::blocking::wait] (ThreadId(1)) park timeout 29.999999369s
    [2026-05-14T18:05:04Z DEBUG reqwest::connect] starting new connection: [https://<redacted>.d.codeartifact.***.amazonaws.com/](https://<redacted>.d.codeartifact.%2A%2A%2A.amazonaws.com/)
    [2026-05-14T18:05:04Z TRACE reqwest::retry] shouldn't retry!
    [2026-05-14T18:05:04Z TRACE reqwest::blocking::wait] wait at most 30s
    [2026-05-14T18:05:04Z TRACE reqwest::blocking::client] closing runtime thread (ThreadId(2))
    [2026-05-14T18:05:04Z TRACE reqwest::blocking::client] signaled close for runtime thread (ThreadId(2))
    [2026-05-14T18:05:04Z TRACE reqwest::blocking::client] (ThreadId(2)) Receiver is shutdown
    [2026-05-14T18:05:04Z TRACE reqwest::blocking::client] (ThreadId(2)) end runtime::block_on
    [2026-05-14T18:05:04Z TRACE reqwest::blocking::client] (ThreadId(2)) finished
    [2026-05-14T18:05:04Z TRACE reqwest::blocking::client] closed runtime thread (ThreadId(2))
    Error: status code '401 Unauthorized': the request was not authorized
    

    cargo install cargo-edit and cargo update both worked within the same workflow, its only cargo upgrade that failed

  11. added 2 commits that reference this issue on May 15, 2026
    b975138
    ff8583c
  12. jaques-sam-tlv commented on Jun 18, 2026

    @jaques-sam-tlv

    Can this be fixed? The issue is still happening with latest version.

  13. r0wdiggity commented on Jun 25, 2026

    @r0wdiggity

    i know you closed my PR because I used AI to help write it and it was too big, but it did resolve the issue, and a lot of the code was testing. If you dont want to accept my code I would ask that you look at the patterns and logic to help implement it, this is blocking us being able to use this since everything we do is private registry, but essentially, there is never an auth token passed in the current fetch, so even though it respects the private repo, it never considers auth.

  14. sunsided commented on Jul 13, 2026

    @sunsided

    Stepped in it just today with 0.13.11 - downgrading to 0.13.1 also fixed it for me.

    It appears like the error may have existed all the time, just that after 0.13.1 we're seeing it.

  15. added a commit that references this issue on Jul 13, 2026
    f32168c
  16. sunsided commented on Jul 16, 2026

    @sunsided

    Prepared a partial fix for the issue in #968, unblocks registries that require a token to log in - in my case, Kellnr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions