How to fix Error: Module not installed in Terraform

TerraformBEGINNERHIGHUpdated Dec 30, 2025· 136 views

The Module not installed error occurs when Terraform cannot find or load a referenced module. This happens when you reference a module in your configuration but haven't run terraform init or the module source is invalid.

Quick fix

Fixes Error: Module not installed

terraform init
  1. Run terraform init to initialize the working directory
  2. Verify the module source path in your Terraform configuration
  3. Clear the Terraform cache and reinitialize
  4. Use terraform init -upgrade for version conflicts
terraform — error
terraform init
Error: Module not installed

What this error means

This error indicates that Terraform has encountered a reference to a module in your configuration (either local or remote) but the module files are not present in the .terraform directory. Terraform manages module dependencies in the .terraform folder after running terraform init. The error prevents Terraform from understanding the full configuration structure needed to plan or apply changes.

Typical symptoms

  • Error message appears when running terraform plan or terraform apply
  • terraform init completed but modules were not fully downloaded
  • .terraform directory exists but is incomplete or corrupted
  • Recent changes to module sources cause initialization failures
  • Remote modules fail to download during terraform init

Common causes

  1. You haven't run terraform init in the working directory yet
  2. The .terraform directory or module cache was deleted or corrupted
  3. Module source path is incorrect or contains typos in the module block
  4. Remote module repository is unreachable or requires authentication
  5. Module version constraints conflict with installed version
  6. Terraform configuration contains invalid syntax in module block declarations
  7. Network connectivity issue preventing remote module downloads

How to fix "Error: Module not installed"

1Run terraform init to initialize the working directory

Execute the terraform init command in your working directory. This command initializes Terraform, installs all required providers, and downloads all referenced modules:

bash
terraform init

This is the most common solution. Terraform will scan your configuration files, find all module references, and download them into the .terraform/modules directory.

2Verify the module source path in your Terraform configuration

Check your .tf files for module declarations. Ensure the source path is correct:

hcl
module "example" {
  source = "./modules/my-module"  # Local module
}

module "vpc" {
  source  = "terraform-aws-modules/vpc/aws"  # Registry module
  version = "~> 5.0"
}

module "network" {
  source = "git::https://github.com/org/repo.git//modules/network"  # Git module
}

Common issues:
- Typos in the source path
- Incorrect case (especially on case-sensitive filesystems)
- Missing the double slash (//) for subdirectories in Git modules
- Outdated or incorrect Git repository URLs

3Clear the Terraform cache and reinitialize

If the error persists after checking the module sources, the cache may be corrupted. Remove it and reinitialize:

bash
rm -rf .terraform
rm .terraform.lock.hcl
terraform init

This removes the cached modules and lock file, forcing Terraform to re-download everything fresh.

4Use terraform init -upgrade for version conflicts

If you recently changed module version constraints, use the -upgrade flag to force Terraform to check for newer versions:

bash
terraform init -upgrade

This is useful when:
- You updated version constraints in your module block
- You want to fetch the latest compatible version
- Previous module versions are cached but no longer valid

5Check network connectivity and authentication

For remote modules (from Git or the Terraform Registry), verify:

1. Internet connectivity: Ensure your system can reach the module source:

bash
ping github.com

2. Git authentication (for private repositories): Configure Git credentials:

bash
git config --global credential.helper store
git clone <your-private-repo>

3. Terraform Registry access: The public registry at registry.terraform.io should be accessible. If you use a private registry, configure it in your .terraformrc:

hcl
credentials "app.terraform.io" {
  token = "YOUR_API_TOKEN"
}

4. Firewall/proxy rules: Ensure no firewall blocks access to module sources.

6Verify module syntax and configuration file validity

Run terraform validate to catch syntax errors in your configuration:

bash
terraform validate

This checks for:
- Invalid module block syntax
- Undefined variable references
- Missing required arguments
- Circular dependencies

Fix any reported errors before running terraform init again.

Advanced notes

Module installation in Terraform follows a specific process: 1) Terraform scans all .tf files for module blocks, 2) it identifies all unique module sources, 3) it checks the lock file (.terraform.lock.hcl) for cached versions, 4) it downloads missing modules to .terraform/modules/, and 5) it creates a manifest file. The lock file ensures reproducible module installations across team members. For remote modules from Git or the Registry, Terraform caches them locally to avoid repeated downloads. The error occurs if any step fails or if the .terraform directory is incomplete. When using local modules, ensure the relative or absolute path exists and contains at least one .tf file. For Registry modules, the format must be namespace/name/provider or organization/module/provider for private registries. Module initialization is independent of provider installation—both happen during terraform init but use separate cache systems.

Frequently asked questions

What does "Error: Module not installed" mean?
terraform directory. terraform folder after running terraform init. The error prevents Terraform from understanding the full configuration structure needed to plan or apply changes.
How do I fix "Error: Module not installed"?
The Module not installed error occurs when Terraform cannot find or load a referenced module. This happens when you reference a module in your configuration but haven't run terraform init or the module source is invalid.
What causes "Error: Module not installed"?
You haven't run terraform init in the working directory yet The .terraform directory or module cache was deleted or corrupted Module source path is incorrect or contains typos in the module block
Is the "Error: Module not installed" error serious?
Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.

Official resources & further reading