4

I am able to ssh into my droplet. Am also able to apt update and apt upgrade.

When I try to run sudo composer self-update or composer update, I am getting connection timeout error.

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

output of ufw status

To      Action    From
22      ALLOW     Anywhere
80      ALLOW     Anywhere
443     ALLOW     Anywhere
25      ALLOW     Anywhere
10000   ALLOW     Anywhere     

output of composer diagnose

Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: FAIL
[Composer\Downloader\TransportException] The "http://packagist.org/packages.json" file    could not be downloaded: failed to open stream: Connection timed out
Checking https connectivity to packagist: FAIL
[Composer\Downloader\TransportException] The "https://packagist.org/packages.json" file    could not be downloaded: failed to open stream: Connection timed out
Checking github.com rate limit: OK
Checking disk free space: OK
Checking composer version: 

[Composer\Downloader\TransportException]                                     
The "https://getcomposer.org/version" file could not be downloaded: failed   
to open stream: Connection timed out

output of composer --version

Composer version 1.0-dev (9e9c1917e1ed9f3f78b195a785aee3c6dc3cb883) 2015-11-23 10:31:23  

output of curl IL http://packagist.org/packages.json

HTTP/1.1 200 OK
Server: nginx
Date: Sun, 10 Dec 2017 08:40:20 GMT
Content-Type: application/json
Content-Length: 1302
Last-Modified: Sun, 10 Dec 2017 08:38:28 GMT
Connection: keep-alive
ETag: "5a2cf284-516"
Cache-Control: private, max-age=0, no-cache
Accept-Ranges: bytes  

I tried to manually get a copy of latest composer but it also doesn't work

output of php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"

PHP Warning:  copy(https://getcomposer.org/installer): failed to open stream: Connection timed out in Command line code on line 1  

What could be the reason? I was all working till about a week ago. I am able to visit (browse) the webpages hosted on my droplett. Am also able to apt update and apt upgrade.

Donkarnash
  • 12,433
  • 5
  • 26
  • 37
  • Have a look at https://getcomposer.org/doc/articles/troubleshooting.md#operation-timed-out-ipv6-issues- - this looks like your problem – Nico Haase Dec 10 '17 at 11:41
  • @NicoHaase This seems to work - atleast get the `sudo composer self-update` worked. However the `composer update` within a project directory is pretty slow - seems to take ages to update the dependencies. I think I will have to google further to understand why the composer update is so slow. Thanks again the issue does seem to be about improper ipv6 config on droplet. If you post it as an answer, I'll be glad to mark it as correct answer. – Donkarnash Dec 10 '17 at 12:23

4 Answers4

9

You can run this command as root to make IPV4 more prior than IPV6:

sudo sh -c "echo 'precedence ::ffff:0:0/96 100' >> /etc/gai.conf"
vvvvv
  • 25,404
  • 19
  • 49
  • 81
JessGabriel
  • 1,062
  • 9
  • 18
  • Thanks, all morning searching for this. It's some sort of problem with my network «I guess» so I don't have access throw ipv6 but it works on ipv4. Thanks Bro. – Pablo Palacios Sep 22 '18 at 13:16
4

https://getcomposer.org/doc/articles/troubleshooting.md#operation-timed-out-ipv6-issues- could solve your problem. And if composer update is slow afterwards, try running it with a more recent PHP version. Running it with PHP 7 instead of PHP 5 will cause a big speedup

Nico Haase
  • 11,420
  • 35
  • 43
  • 69
0

I also found a bug on executing composer command this last time about this timeout. Run "compose diag" then restart the command solved the problem if it is not related to ipv6

JessGabriel
  • 1,062
  • 9
  • 18
  • Can you explain that further? How does `composer diag` solve any problem? – Nico Haase Oct 09 '19 at 08:53
  • I don't know what really happen but sometimes it resolves the problem. Looks like `composer diag` don't diagnose only but trying to solve something or change something too – JessGabriel Oct 09 '19 at 10:02
0

My Issue is caused by PHP 7.2, after switch back to PHP 7.1 'sphp 7.1', run the command 'composer update' again, and it works

Mark Khor
  • 396
  • 5
  • 7