如何解决类似 curl: (7) Failed to connect to raw.githubusercontent.com port 443: 拒绝链接

2,176 阅读1分钟

最近在安装ohmyzsh的过程中遇到这个问题:

% sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
curl: (7) Failed to connect to raw.githubusercontent.com port 443: 拒绝连接

域名被墙了,要么搭ti zi,还有一种办法是在hosts文件中添加域名到ip的映射, 域名的ip可以同这个网址获得:www.ipaddress.com/

/etc/hosts 文件中添加以下内容即可:

199.232.68.133 raw.githubusercontent.com
199.232.68.133 user-images.githubusercontent.com
199.232.68.133 avatars2.githubusercontent.com
199.232.68.133 avatars1.githubusercontent.com

完美解决上面的问题:

% sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
Cloning Oh My Zsh...
正克隆到 '/home/zjl/.oh-my-zsh'...
remote: Enumerating objects: 1155, done.
remote: Counting objects: 100% (1155/1155), done.
remote: Compressing objects: 100% (1121/1121), done.
remote: Total 1155 (delta 20), reused 1074 (delta 18), pack-reused 0
接收对象中: 100% (1155/1155), 775.06 KiB | 11.00 KiB/s, 完成.
处理 delta 中: 100% (20/20), 完成.

Looking for an existing zsh config...
Found ~/.zshrc. Backing up to /home/zjl/.zshrc.pre-oh-my-zsh
Using the Oh My Zsh template file and adding it to ~/.zshrc.

         __                                     __
  ____  / /_     ____ ___  __  __   ____  _____/ /_
 / __ \/ __ \   / __ `__ \/ / / /  /_  / / ___/ __ \
/ /_/ / / / /  / / / / / / /_/ /    / /_(__  ) / / /
\____/_/ /_/  /_/ /_/ /_/\__, /    /___/____/_/ /_/
                        /____/                       ....is now installed!


Before you scream Oh My Zsh! please look over the ~/.zshrc file to select plugins, themes, and options.

• Follow us on Twitter: https://twitter.com/ohmyzsh
• Join our Discord server: https://discord.gg/ohmyzsh
• Get stickers, shirts, coffee mugs and other swag: https://shop.planetargon.com/collections/oh-my-zsh