This error occurs when Terraform cannot locate or access a remote module you're trying to use. Common causes include incorrect source paths, authentication issues, network connectivity problems, or missing initialization steps.
The 'Unable to find remote module source' error indicates that Terraform attempted to load a module from a remote location but could not find it. This happens during the terraform init phase when Terraform tries to download and cache the module. The error can stem from configuration issues, credential problems, network failures, or version mismatches. Terraform needs to successfully resolve the module source to proceed with initialization.
Double-check the module source string in your Terraform configuration. Ensure there are no typos and that the path follows the correct format for your module type.
For Terraform Registry modules:
module "example" {
source = "namespace/name/provider"
version = "1.0.0"
}For Git-based modules, ensure the URL is properly formatted:
module "example" {
source = "git::https://github.com/org/repo.git//modules/example"
}Clear the local module cache and force Terraform to re-download all modules. This resolves issues with corrupted or outdated cached modules.
terraform init -upgradeThe -upgrade flag ensures Terraform fetches the latest allowed versions matching your version constraints and refreshes the module cache.
For Terraform Registry modules, verify the version tag exists in the source. Check the Terraform Registry directly or use the API:
curl https://registry.terraform.io/v1/modules/namespace/name/provider/versionsFor Git-based modules, verify the branch or tag exists:
git ls-remote https://github.com/org/repo.git | grep refs/tags/v1.0.0If using private modules, ensure proper credentials are configured.
For Terraform Cloud/Enterprise:
terraform loginFor GitHub private repositories, configure Git credentials or use SSH keys:
git config --global credential.helper storeFor private module registries, update ~/.terraformrc:
credentials "tfe.example.com" {
token = "YOUR_API_TOKEN"
}Verify that your network can reach the module source. Test connectivity to the registry or repository:
curl -v https://registry.terraform.io
curl -v https://github.comIf behind a corporate proxy or firewall, configure Terraform to use the proxy settings. Add these environment variables:
export HTTP_PROXY=http://proxy.example.com:8080
export HTTPS_PROXY=http://proxy.example.com:8080
terraform initSet TF_LOG to DEBUG to see detailed information about module resolution attempts. This helps identify exactly where the failure occurs:
export TF_LOG=DEBUG
terraform init > terraform-debug.log 2>&1Examine the log output to find the specific error from the registry or repository. Common patterns include connection timeouts, authentication failures, or 404 errors indicating the module doesn't exist at that location.
When troubleshooting in CI/CD environments, ensure that the environment where terraform init runs has the same network access and credentials as your local machine. API tokens in .terraformrc should be handled via environment variables (TF_TOKEN_<hostname>) for better security. For modules with subdirectories, use the // syntax: source = "git::https://github.com/org/repo.git//modules/subdir". If using Terraform Cloud with private module registries that use URL subpaths, note that some configurations may require explicit registry declarations in .terraformrc rather than relying on short-form module addresses.
Error: Error installing helm release: cannot re-use a name that is still in use
How to fix "release name in use" error in Terraform with Helm
Error: Error creating GKE Cluster: BadRequest
BadRequest error creating GKE cluster in Terraform
Error: External program failed to produce valid JSON
External program failed to produce valid JSON
Error: Unsupported argument in child module call
How to fix "Unsupported argument in child module call" in Terraform
Error: network is unreachable
How to fix "network is unreachable" in Terraform