curl error 28 while downloading https://repo.packagist.org/packages.json: Connection timeout after 10004 ms

curl error 28 while downloading https://repo.packagist.org/packages.json: Connection timeout after 10004 ms

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

Curl Error 28 While Downloading Packagist: Connection Timeout After 10004 ms

When running composer create-project laravel/laravel example-app, you might encounter a fatal error in CurlDownloader.php stating: curl error 28 while downloading https://repo.packagist.org/packages.json: Connection timeout after 10004 ms. This message indicates that Composer attempted to fetch the list of available packages from the Packagist repository but failed because the connection was closed or timed out before the download completed.

The specific error code 28 in cURL terminology is a "Connection Timeout" error. The log explicitly notes that 10,004 milliseconds (roughly 10 seconds) elapsed without a successful response from the server. This usually happens when the network stack cannot establish a handshake with the remote host within the configured limit, or if the remote server drops the connection abruptly.

Root Causes and Network Environment

Before modifying Composer's configuration, it is critical to isolate whether this is a local environment issue or a broader network problem. The error often stems from corporate firewalls, restrictive proxy settings, or unstable internet connections that interrupt TCP handshakes. If you are behind a corporate firewall, the default timeout of 10 seconds might be insufficient for the initial DNS resolution or SSL handshake, especially if the server is geographically distant or under heavy load.

Another common culprit is the curl command itself. While PHP's cURL extension is powerful, the underlying system's network configuration can override defaults. If your server or local machine has a globally configured timeout that is stricter than Composer's internal settings, you will see this error regardless of Composer's config files. Check if other tools like wget or ping to repo.packagist.org succeed; if they fail with similar timeouts, the issue lies in your network infrastructure rather than Composer.

Resolving the Timeout via Configuration

The most direct fix is to extend the timeout duration for cURL operations within Composer. You can do this by modifying the config/config.php file located in your Composer installation directory (typically ~/.composer/config.json or ./vendor/composer/config.json depending on your setup).

Add or update the timeout setting as follows:

{
    "config": {
        "platform.check": false,
        "allow-plugins": {
            "php-http/discovery": true
        },
        "http-timeout": 0
    }
}

Setting "http-timeout": 0 tells cURL to use its default timeout limit, which is generally more robust than the hardcoded defaults in some environments. However, if you need a specific duration, you can set it to a value like 60 seconds (60000 ms) to ensure there is ample time for large metadata files to download:

{
    "config": {
        "http-timeout": 60
    }
}

After updating the configuration, rerun the creation command. If the error persists, check your environment variables. Sometimes COMPOSER_MEMORY_LIMIT or other PHP settings interfere with stream operations, though this is less common for connection timeouts.

Using a Mirror Repository

If changing timeout values does not resolve the issue, consider switching to a Packagist mirror. Some regions have mirrors hosted on local servers that provide faster access and lower latency compared to the primary repo.packagist.org endpoint.

You can configure Composer to use a mirror by adding the following to your composer.json file under the repositories key:

{
    "repositories": [
        {
            "type": "packagist",
            "url": "https://packagist.php.net"
        }
    ]
}

Note that mirror availability varies by region, and not all mirrors are actively maintained. If a mirror is unstable, it can cause similar errors. Always verify the mirror's status before relying on it for production builds.

When to Escalate

If you have adjusted timeouts, verified your network connectivity, and tested multiple mirrors without success, the issue likely lies with the upstream Packagist service or your ISP's routing to that specific IP address. In rare cases, DNS resolution failures can mimic connection timeouts. Try forcing a direct IP connection or flushing your DNS cache (sudo systemd-resolve --flush-caches on Linux systems) to rule out caching issues.

If you are deploying this in a production environment and the issue persists despite these steps, consult your network administrator regarding firewall rules that may be blocking outbound connections to the Packagist domain or its associated CDN nodes.

Our network