Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cargo tries to resolve an incorrect host name to download crates #7515

Closed
ksqsf opened this issue Oct 16, 2019 · 11 comments
Closed

Cargo tries to resolve an incorrect host name to download crates #7515

ksqsf opened this issue Oct 16, 2019 · 11 comments
Labels
C-bug Category: bug

Comments

@ksqsf
Copy link

ksqsf commented Oct 16, 2019

Problem

Cargo sometimes tries to resolve an incorrect host name to download crates. This problem is intermittent.

warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates)
error: failed to download from `https://crates-io.proxy.ustclug.org/api/v1/crates/tokio-core/0.1.17/download`

Caused by:
  [6] Couldn't resolve host name (Could not resolve host: crates)

... while curl can indeed download data.

Steps

  1. Enable USTCLUG reverse proxy service for crates.io
  2. cargo build and it automatically downloads crates from that site
  3. Fail: error: failed to download from https://crates-io.proxy.ustclug.org/api/v1/crates/xml-rs/0.7.0/download Caused by: [6] Couldn't resolve host name (Could not resolve host: crates)`

Possible Solution(s)

I'm not familiar with cargo, so I don't know why this happens. This might be a problem with our reverse proxy set-up, but I'd like a pointer on how to figure out the root cause. :-)

Notes

Output of cargo version: cargo 1.37.0 (9edd089 2019-08-02)

Another report

@ksqsf ksqsf added the C-bug Category: bug label Oct 16, 2019
@alexcrichton
Copy link
Member

Thanks for the report! Can you try setting http.debug in .cargo/config and gist the output of the result? You may want to try it on a smaller project as well which only attempts to download one crate to avoid lots of interleaved output.

[http]
# This setting can be used to help debug what's going on with HTTP requests made
# by Cargo. When set to `true` then Cargo's normal debug logging will be filled
# in with HTTP information, which you can extract with
# `CARGO_LOG=cargo::ops::registry=debug` (and `trace` may print more).
#
# Be wary when posting these logs elsewhere though, it may be the case that a
# header has an authentication token in it you don't want leaked! Be sure to
# briefly review logs before posting them.
debug = false

@ksqsf
Copy link
Author

ksqsf commented Oct 18, 2019

http debug trace

(Attempted to obtain a smaller trace but the problem suddenly is gone...)

@ksqsf
Copy link
Author

ksqsf commented Oct 18, 2019

Thanks for the hint! So here's the problem.

[2019-10-18T07:18:23Z DEBUG cargo::ops::registry] http-debug: < HTTP/2 302 
[2019-10-18T07:18:23Z DEBUG cargo::ops::registry] http-debug: < server: nginx
[2019-10-18T07:18:23Z DEBUG cargo::ops::registry] http-debug: < date: Fri, 18 Oct 2019 07:18:23 GMT
[2019-10-18T07:18:23Z DEBUG cargo::ops::registry] http-debug: < content-type: text/html
[2019-10-18T07:18:23Z DEBUG cargo::ops::registry] http-debug: < content-length: 154
[2019-10-18T07:18:23Z DEBUG cargo::ops::registry] http-debug: < location: https:///crates/unicase/unicase-2.5.1.crate
[2019-10-18T07:18:23Z DEBUG cargo::ops::registry] http-debug: < 
[2019-10-18T07:18:23Z DEBUG cargo::ops::registry] http-debug: * Ignoring the response-body
[2019-10-18T07:18:23Z DEBUG cargo::ops::registry] http-debug: * Issue another request to this URL: 'https:///crates/unicase/unicase-2.5.1.crate'
[2019-10-18T07:18:23Z DEBUG cargo::ops::registry] http-debug: * Unwillingly accepted illegal URL using 3 slashes!

The request is incorrectly redirected. Likely a mistake in our setup. Closing.

@ksqsf ksqsf closed this as completed Oct 18, 2019
@JavierLiu
Copy link

Hello, I have encountered the same problem as you. May I know your solution?
Thanks in advance!

@s977120
Copy link

s977120 commented Apr 29, 2020

Hello, I have encountered the same problem as you. May I know your solution?
Thanks in advance!

+1

@fengerzh
Copy link

It's caused by too many connections. Add following command before any of your cargo command:

CARGO_HTTP_MULTIPLEXING=false

For example:

CARGO_HTTP_MULTIPLEXING=false cargo install cargo-generate

Or, just add this env setting in your .bash_profile:

export CARGO_HTTP_MULTIPLEXING=false

@passiondu
Copy link

It's caused by too many connections. Add following command before any of your cargo command:

CARGO_HTTP_MULTIPLEXING=false

For example:

CARGO_HTTP_MULTIPLEXING=false cargo install cargo-generate

Or, just add this env setting in your .bash_profile:

export CARGO_HTTP_MULTIPLEXING=false

thank you ,

@dmartin
Copy link

dmartin commented Feb 2, 2022

I am seeing a similar issue intermittently in CI when building a crate using maturin:

It's similar to the original report, though the hostname appears to be crates.io rather than crates.

out: #24 38.66 💥 maturin failed
out: #24 38.66   Caused by: Cargo metadata failed. Does your crate compile with `cargo build`?
out: #24 38.66   Caused by: `cargo metadata` exited with an error:     Updating crates.io index
out: #24 38.66  Downloading crates ...
out: #24 38.66 warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates.io)
out: #24 38.66 warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates.io)
out: #24 38.66 warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates.io)
out: #24 38.66 warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates.io)
out: #24 38.66 warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates.io)

Is this truly caused by too many connections, as mentioned above? If so, some sort of throttling would be preferable to failing the build. Adding the CARGO_HTTP_MULTIPLEXING=false flag as mentioned above doesn't seem ideal as this only happens intermittently and seemingly only on certain hosts.

gavinmorrow added a commit to gavinmorrow/Pollywog that referenced this issue Jul 20, 2023
Attempt to fix, might work.

Source: rust-lang/cargo#7515
@DelSkayn
Copy link

DelSkayn commented Jul 20, 2023

I encountered a similar issue in github CI with a different hostname: static.crates.iocrates

Downloading crates ...
warning: spurious network error (3 tries remaining): [6] Couldn't resolve host name (Could not resolve host: static.crates.iocrates)
warning: spurious network error (3 tries remaining): [6] Couldn't resolve host name (Could not resolve host: static.crates.iocrates)
warning: spurious network error (3 tries remaining): [6] Couldn't resolve host name (Could not resolve host: static.crates.iocrates)
warning: spurious network error (3 tries remaining): [6] Couldn't resolve host name (Could not resolve host: static.crates.iocrates)
warning: spurious network error (3 tries remaining): [6] Couldn't resolve host name (Could not resolve host: static.crates.iocrates)
warning: spurious network error (3 tries remaining): [6] Couldn't resolve host name (Could not resolve host: static.crates.iocrates)
...

Trying to build resulted in these error twice before suddenly working the third time.

@Eh2406
Copy link
Contributor

Eh2406 commented Jul 21, 2023

crates.io was having an outage see https://status.crates.io/incidents/qtcxln295f0n and https://blog.rust-lang.org/inside-rust/2023/07/21/crates-io-postmortem.html

@balqaasem
Copy link

My solution is:

git config --global http.proxy http://127.0.0.1:4780

It worked for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

10 participants