Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"https://packagist.org/packages.json" file could not be downloaded: failed to open stream: Operation timed out

This morning, I ran this command

composer create-project laravel/laravel laravel-4.2 4.2 --prefer-dist

I kept getting

enter image description here

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-mode for more info

Anyone know how to avoid this ?

like image 583
code-8 Avatar asked Sep 21 '18 14:09

code-8


3 Answers

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.

# dig +short repo.packagist.org
142.44.164.255
# echo "142.44.164.255 repo.packagist.org" >> /etc/hosts

More details here!

like image 170
garrettmills Avatar answered Oct 19 '22 07:10

garrettmills


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

I got the answer here and it works like voodoo...

like image 6
The Billionaire Guy Avatar answered Oct 19 '22 06:10

The Billionaire Guy


For me it was ipv6, I disabled it using: networksetup -setv6off Wi-Fi on macOS. Worked like a charm.

Solution found here: https://getcomposer.org/doc/articles/troubleshooting.md#operation-timed-out-ipv6-issues-

like image 6
zeus Avatar answered Oct 19 '22 07:10

zeus