cargo: unable to connect to index.crates.io

Problem

When attempting to download crates, I get a warning: spurious network error (3 tries remaining): [35] SSL connect error (Recv failure: Connection was reset). After the next tries it causes the install to fail with: Caused by: [35] SSL connect error (Recv failure: Connection was reset) This started happening on my new windows 11 machine.

Steps

Clean installation on a new windows 11 system, all updates installed. Attempting to install any crate fails.

Possible Solution(s)

No response

Notes

The toolchain used makes no difference. Already tried setting these options in the global config.toml, based on some previous issues: [source.crates-io] index = “https://github.com/rust-lang/crates.io-index” # I set the source to the official github index

[http] proxy = “” # leaving this as a blank string resets proxy to default http.check-revoke = false #check-revoke = false

None of which worked. I am not using Windows defender. I am using Eset antivirus as I was on my previous computer, where I didn’t have this problem.

Version

cargo 1.78.0-nightly (fc1d58fd0 2024-02-09)
release: 1.78.0-nightly
commit-hash: fc1d58fd0531a57a6b942a14cdcdbcb82ece16f3
commit-date: 2024-02-09
host: x86_64-pc-windows-msvc
libgit2: 1.7.2 (sys:0.18.2 vendored)
libcurl: 8.6.0-DEV (sys:0.4.71+curl-8.6.0 vendored ssl:Schannel)
os: Windows 10.0.22635 (Windows 11 Core) [64-bit]

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 7
  • Comments: 22 (4 by maintainers)

Most upvoted comments

If someone is still going through this issue on Windows, please try by adding registries.crates-io.protocol = "git" to /.cargo/config.toml. It worked for me.

Not at all! I am on Linux and it is a DNS issue when building an image with a Rust App. On my host, everything works fine! It seems that in the Dockerfile, when cargo build is triggered, cargo update execute first to update the index with crates.io, and it is here I got the issue. Even more, the initial image is downloaded successfully!

Something is wrong with index.crates.io and their DNS …

Since the issue author has their original problem solved. I am going to close this.

If anyone still has networking issue with the latest Cargo, feel free to open a new issue. Thank you all!

a (clearly suboptimal) workaround is to make cargo use git for the protocol, and git-cli for its git work … the CLI can be whatever you have installed and it usually uses ipv4 instead of ipv6 … so …

cargo-net.git-fetch-with-cli = true
registries.crates-io.protocol = "git"

in cargo.toml should be enough for that …

now if whatever git-cli you have is still doing git via ipv6, you could configure it with something like :

git config --global url."https://github.com/".insteadOf git://github.com/
git config --global url."https://".insteadOf git://

there’s also the more intrusive way of just going into windows network adapter advanced setting, finding the ipv4 and ipv6 specific advanced properties and configuring the metric manually to give ipv4 lower (i.e higher preference) metric compared to ipv6 instead of the typically selected ‘Automatic metric’ checkbox for both of them … in theory that should make windows prefer the lower-metric option

and for those who might only occasionally run into the issue, you could prob simply get by increasing the number or retries cargo makes before it gives up … by setting up CARGO_NET_RETRY=10 etc in the env (instead of the default 3)

(and for those who know what they’re doing and find that it is indeed a ssl cert revocation issue for them, you could add CARGO_HTTP_CHECK_REVOKE=false to your env too)

If someone is still going through this issue on Windows, please try by adding registries.crates-io.protocol = "git" to /.cargo/config.toml. It worked for me.

I tried that before I found the workaround for me with ipv4 only. Getting the index worked. Downloading the crates didn’t work for me.