Trouble shooting on Composer timeout

Published on November 20, 2019 at 11:01:09 PM GMT+8 by Administrator

This article contain the tips on how to avoid the composer timeout. The "https://repo.packagist.org/packages.json" file could not be downloaded: failed to open stream.


Trouble shooting on Composer timeout

Operation timed out (IPv6 issues)

You may run into errors if IPv6 is not configured correctly. A common error is:

The "https://getcomposer.org/version" file could not be downloaded: failed to
open stream: Operation timed out

We recommend you fix your IPv6 setup. If that is not possible, you can try the following workarounds:

Workaround Linux:

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:

sudo sh -c "echo 'precedence ::ffff:0:0/96 100' >> /etc/gai.conf"

Workaround Windows:

On windows the only way is to disable ipv6 entirely I am afraid (either in windows or in your home router).

Workaround Mac OS X:

Get name of your network device:

networksetup -listallnetworkservices

Disable IPv6 on that device (in this case "Wi-Fi"):

networksetup -setv6off Wi-Fi

Run composer ...

You can enable IPv6 again with:

networksetup -setv6automatic Wi-Fi

That said, if this fixes your problem, please talk to your ISP about it to try and resolve the routing errors. That's the best way to get things resolved for everyone.

Composer hangs with SSH ControlMaster

When you try to install packages from a Git repository and you use the ControlMaster setting for your SSH connection, Composer might hang endlessly and you see a sh process in the defunct state in your process list.

The reason for this is a SSH Bug: https://bugzilla.mindrot.org/show_bug.cgi?id=1988

As a workaround, open a SSH connection to your Git host before running Composer:

ssh -t [email protected]
composer update

See also https://github.com/composer/composer/issues/4180 for more information.


----------------------------------------------------------

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