Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

Composer stops with curl error 28 while downloading packages

Errorcurl error 28 while downloading

Short answer

Curl error 28 is a timeout. Composer either waited too long for a slow transfer, or never got a connection because the IPv6 route is broken. Raise the stall timeout for slow links, force IPv4 with COMPOSER_IPRESOLVE=4 for broken IPv6, and check any antivirus web scanner.

  • Applies to Composer 2.8, PHP 8.3, Ubuntu 24.04
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Run Composer's own self-check. It tests the connection to Packagist and GitHub and tells you whether IPv6 or a proxy is involved.

    composer diagnose
  2. 2Match what you see, then jump to its fix

    1. 1Less than 1 bytes/sec transferred the last 30 seconds, or Operation timed out after 300000 millisecondsThe transfer is slow and Composer gives upFix
    2. 2The timeout appears before any data arrives, on a network or server where IPv6 is advertised but does not work.A broken IPv6 route makes connections hangFix
    3. 3The same timeout keeps coming back, even though other machines on another network download fine.A security product scans the HTTP trafficFix

What does the error look like?

  • curl error 28 while downloading
  • Operation timed out after 300000 milliseconds
  • Operation too slow. Less than 1 bytes/sec transferred the last 30 seconds

Cause 1 of 3

The transfer is slow and Composer gives up

1Check

The two messages mean different limits. The 30-second one is Composer's stall timeout (nothing arrived for 30 seconds). The 300000 ms one is PHP's socket timeout.

php -i | grep default_socket_timeout

2Fix

Raise the stall timeout for this run (0 disables it), and raise default_socket_timeout in the php.ini that the command line uses.

COMPOSER_HTTP_STALL_TIMEOUT=120 composer install

; php.ini (CLI)
default_socket_timeout = 600

3Verify

Run the install again and watch it finish without the timeout.

composer install -vvv

Confirmed by getcomposer.org

Did this fix it?

Cause 2 of 3

A broken IPv6 route makes connections hang

1Check

Composer can force IPv4 for a single run when the curl extension is used. If that run succeeds, IPv6 was the problem.

COMPOSER_IPRESOLVE=4 composer diagnose

2Fix

Fix the IPv6 setup if you can. Otherwise keep IPv4 forced for Composer, or on Linux prefer IPv4 addresses system-wide.

COMPOSER_IPRESOLVE=4 composer install

# Linux, system-wide preference for IPv4
sudo sh -c "echo 'precedence ::ffff:0:0/96 100' >> /etc/gai.conf"

3Verify

Run Composer again without the variable if you changed gai.conf.

composer diagnose

Confirmed by getcomposer.org

Did this fix it?

Cause 3 of 3

A security product scans the HTTP traffic

1Check

Composer switches to a degraded network mode after it first detects a network problem. If timeouts keep repeating, something between you and Packagist may be interfering.

composer diagnose -vvv

2Fix

If you run ESET, turn off the HTTP scanner under web access protection and try again. Otherwise test from another network to rule out the firewall.

# ESET: Web access protection > HTTP scanner > off, then rerun composer

3Verify

Run the install again.

composer install

Confirmed by getcomposer.org

Did this fix it?

How do I stop it coming back?

  • Run composer diagnose before reporting a download problem; it shows the failing host.
  • In CI, cache the Composer download directory so a slow mirror does not block every build.
  • If IPv6 is advertised on a server but not routed, fix it at the network level rather than working around it per tool.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Back end

CodeIgniter 4 cannot write its cache files

CodeIgniter\Cache\Exceptions\CacheException: Cache unable to write to /var/www/app/writable/cache/

CodeIgniter 4's file cache needs a cache directory that the web server can really write to.

2 causes, each with a fix

Back end

CodeIgniter 3 loads the model but the property is undefined

The model name you are loading is the name of a resource that is already being used: user

CodeIgniter 3 expects a model file named like its class, with the first letter capitalised, for example User_model.php holding class User_model.

2 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.