卷曲:(6)无法解析主机:services.gradle.org

卷曲:(6)无法解析主机:services.gradle.org

如果Ubuntu Server执行in:

curl https://services.gradle.org/distributions/gradle-7.5.1-bin.zip -O

出现:

 % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:--  0:00:19 --:--:--     0curl: (6) Could not resolve host: services.gradle.org

观察该curl: (6) Could not resolve host: services.gradle.org部分。

如果在in中Fedora Server执行相同的命令,则显示:

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0

没有错误,但gradle-7.5.1-bin.zip文件是空的。

如果您打开网络浏览器并将其放入https://services.gradle.org/distributions/gradle-7.5.1-bin.zip地址栏中,下载过程将自动开始。

那么如何解决这种情况呢?

笔记以防万一,两个 Linux 都运行为虚拟机VirtualBox

答案1

显然你的ubuntu服务器中的DNS解析有问题

尝试设置其他 DNS 服务器,例如8.8.8.81.1.1.1

查看内容/etc/resolv.conf并设置nameserver 8.8.8.8

更新:

修复 DNS 问题后,添加允许其“遵循重定向”的-L选项curl

这里的问题是 URL 实际上并不提供文件,而是重定向到实际托管该文件的另一个 URL。这是在浏览器中自动完成的,但需要在选项curl中完成。-L

wget请参阅示例的输出:

% wget https://services.gradle.org/distributions/gradle-7.5.1-bin.zip
--2022-11-07 11:16:12--  https://services.gradle.org/distributions/gradle-7.5.1-bin.zip
Resolving services.gradle.org (services.gradle.org)... 104.18.191.9, 104.18.190.9
Connecting to services.gradle.org (services.gradle.org)|104.18.191.9|:443... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://downloads.gradle-dn.com/distributions/gradle-7.5.1-bin.zip [following]
--2022-11-07 11:16:12--  https://downloads.gradle-dn.com/distributions/gradle-7.5.1-bin.zip
Resolving downloads.gradle-dn.com (downloads.gradle-dn.com)... 104.18.164.99, 104.18.165.99
Connecting to downloads.gradle-dn.com (downloads.gradle-dn.com)|104.18.164.99|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 120635534 (115M) [application/zip]
Saving to: ‘gradle-7.5.1-bin.zip.1’

gradle-7.5.1-bin.zip.1                             100%[================================>] 115,05M  5,31MB/s    in 21s

2022-11-07 11:16:34 (5,43 MB/s) - ‘gradle-7.5.1-bin.zip.1’ saved [120635534/120635534]

301 Moved Permanently是重定向,之后是新的 URL

相关内容