Skip to content
Latchkey

Composer "The X repository could not be loaded" / 404 in CI

Composer tried to read a repository it was configured to use (a Packagist mirror, a private Satis/Repman feed, or a single package URL) and the server returned 404 or the metadata file was unreachable, so it cannot list any packages from it.

What this error means

composer install fails with "The \"https://repo.example.com/packages.json\" file could not be downloaded (HTTP/1.1 404 Not Found)" and "The X repository could not be loaded".

composer
[Composer\Downloader\TransportException]
The "https://repo.example.com/packages.json" file could not be downloaded
(HTTP/1.1 404 Not Found)
The "https://repo.example.com" repository could not be loaded.

Common causes

A wrong or moved repository URL

The repositories entry points at a path that no longer serves packages.json, so the feed returns 404.

A private feed reached without credentials

The repository requires auth; an unauthenticated request is answered with 404 (to hide existence) rather than 401.

How to fix it

Verify the repository URL and metadata path

  1. Confirm the repositories URL in composer.json serves a reachable packages.json.
  2. For a private feed, add credentials via COMPOSER_AUTH so it returns 200.
  3. Re-run install once the feed loads.
composer.json
{
  "repositories": [
    { "type": "composer", "url": "https://repo.example.com" }
  ]
}

Authenticate a private Composer repository

Supply an http-basic credential for the host so the metadata file is served instead of 404.

.github/workflows/ci.yml
env:
  COMPOSER_AUTH: '{"http-basic":{"repo.example.com":{"username":"ci","password":"${{ secrets.REPO_TOKEN }}"}}}'

How to prevent it

  • Keep repository URLs in composer.json current and reachable.
  • Authenticate private feeds in CI so they return 200, not 404.
  • Monitor the availability of self-hosted Satis/Repman feeds.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →