Skip to content
Latchkey

Terraform "Module not found" in a private registry in CI

Terraform queried a private module registry and it returned not found. Either the namespace/name/provider address is wrong, or the credentials the runner sent do not grant visibility to that module.

What this error means

terraform init stops with "Error: Module not found" or a 404 from the module registry for a host/namespace/name/provider source.

Terraform
Error: Failed to retrieve available versions for module "network"

Could not retrieve the list of available versions for module network from
app.terraform.io: module "app.terraform.io/acme/network/aws" not found.

Common causes

A wrong module address

The namespace/name/provider (or host prefix) is misspelled, so the private registry has no matching module.

The token cannot see the module

The credentials are valid but scoped to a different organization, so the module is effectively not found for this token.

How to fix it

Confirm the exact private module address

  1. Open the module in the private registry and copy its exact source string.
  2. Match the host, namespace, name, and provider in the module block.
  3. Re-run init to confirm the module resolves.
main.tf
module "network" {
  source  = "app.terraform.io/acme/network/aws"
  version = "~> 1.2"
}

Use a token scoped to the module org

Set a TF_TOKEN_<host> credential for a principal that can read the module.

.github/workflows/ci.yml
env:
  TF_TOKEN_app_terraform_io: ${{ secrets.TFC_TOKEN }}

How to prevent it

  • Copy private module addresses directly from the registry.
  • Scope registry tokens to the org that owns the module.
  • Pin a version so a real release is requested.

Frequently asked questions

What causes ""Module not found" (private registry)"?
The namespace/name/provider (or host prefix) is misspelled, so the private registry has no matching module.
How do I fix "Module not found" (private registry)?
Confirm the exact private module address

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card