laravel 无法下载“https://packagist.org/packages.json”文件:无法打开流:操作超时
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/52446329/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
"https://packagist.org/packages.json" file could not be downloaded: failed to open stream: Operation timed out
提问by cyber8200
This morning, I ran this command
今天早上,我运行了这个命令
composer create-project laravel/laravel laravel-4.2 4.2 --prefer-dist
I kept getting
我一直得到
The "https://packagist.org/packages.json" file could not be downloaded: failed to open stream: Operation timed out
Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-modefor more info
无法下载“ https://packagist.org/packages.json”文件:无法打开流:操作超时正在
使用降级模式重试,请检查https://getcomposer.org/doc/articles/troubleshooting.md#降级模式了解更多信息
Anyone know how to avoid this ?
有谁知道如何避免这种情况?
回答by The Dead Guy
try this solution worked for me!
试试这个解决方案对我有用!
"repositories": [
{
"type": "composer",
"url": "https://packagist.org"
},
{ "packagist": false }
]
and run composer:update
once again. If not then run composer self-update
并composer:update
再次运行。如果没有那么run composer self-update
I got the answer hereand it works like voodoo...
我在这里得到了答案,它就像巫毒教一样......
回答by glmdev
For me, this wasn't an issue with my internet connection speed, but it was a issue with IPv6 resolution of "repo.packagist.org". I got around this issue by adding the IPv4 address to my hosts file. It's a hack, but it works.
对我来说,这不是我的互联网连接速度的问题,而是“repo.packagist.org”的 IPv6 分辨率问题。我通过将 IPv4 地址添加到我的主机文件来解决这个问题。这是一个黑客,但它的工作原理。
# dig +short repo.packagist.org
142.44.164.255
# echo "142.44.164.255 repo.packagist.org" >> /etc/hosts
回答by Elisha Senoo
回答by Ariful Islam
This problem occurs for your low speed or bad connection. It failed to access internet and download repository. Check your internet connection and try again to connect your console to the internet.
出现此问题是由于您的速度低或连接不良。它无法访问互联网和下载存储库。检查您的互联网连接,然后再次尝试将您的主机连接到互联网。
回答by online Thomas
I have heard this problem can occur if you live in an area behind a government firewall, you might want to test if it works when behind a VPN.
我听说如果您住在政府防火墙后面的区域,可能会出现此问题,您可能想测试它是否在 VPN 后面工作。
回答by sathyakrishnapalani
Mostly it happens when you did not get the response from the server. 1. check internet connection. 2. check any proxy block your response from the server. 3. if block proxy. When installing the composer that time you set proper proxy configuration on your installation process. 4. You should check your admin user privilege. 5. If you guest or limited account. You can not download any file from the outside server.
大多数情况下,当您没有收到服务器的响应时,就会发生这种情况。1. 检查网络连接。2.检查任何代理阻止您来自服务器的响应。3.如果块代理。安装 Composer 时,您在安装过程中设置了正确的代理配置。4. 您应该检查您的管理员用户权限。5.如果你是guest或者受限账号。您不能从外部服务器下载任何文件。
回答by Gurpal singh
The problem is due to slow internet connection or no internet. If there is no internet then The packages are unable to download from the server. that's why it gives this error i had face many time.
问题是由于互联网连接缓慢或没有互联网。如果没有互联网,则无法从服务器下载软件包。这就是为什么它会出现我多次遇到的错误。
回答by Vincent
Clearing the DNS cache fixed this for me.
清除 DNS 缓存为我解决了这个问题。
In the terminal execute:
在终端执行:
dscacheutil -flushcache
sudo killall -HUP mDNSResponder
回答by DevonDahon
Switch to a mirror according to your location : https://packagist.org/mirrors
根据您的位置切换到镜像:https: //packagist.org/mirrors
Especially if you're in China.
特别是如果你在 CN 。
回答by Gerhardo Cardoso
On linux, it seems that running this command helps to make ipv4 traffic have a higher prio than ipv6, which is a better alternative than disabling ipv6 entirely:
在 linux 上,似乎运行此命令有助于使 ipv4 流量具有比 ipv6 更高的优先级,这是比完全禁用 ipv6 更好的选择:
Workaround Linux:
解决方法 Linux:
sudo sh -c "echo 'precedence ::ffff:0:0/96 100' >> /etc/gai.conf"enter image description here
sudo sh -c "echo 'precedence ::ffff:0:0/96 100' >> /etc/gai.conf"在此处输入图像描述