Solution skill
Error: Failed to download module
Complete solution
Fixes OpenTofu's 'Error: Failed to download module' at tofu init by tracing the bad module source. Use when init names a module whose source URL, ref, or registry path doesn't resolve. Not for 'Module not installed' (you skipped init) or provider download errors.
TL;DR: tofu init can't fetch a module source. The error shows the module address and the exact source URL it tried. Check the source for typos, confirm the repo, ref, or registry path actually exists (and that you have access, for private ones), then re-init.
Error: Failed to download module
Could not download module "ddn_exascaler" (modules/DDN-EXAScaler/main.tf:38) source code from
"git::https://github.com/DDNStorage/exascaler-cloud-terraform.git?ref=78deadb": error downloading
'https://github.com/DDNStorage/exascaler-cloud-terraform.git?ref=78deadb': /usr/bin/git exited with 128: Cloning into
'.terraform/modules/tmplustrefs.ddn_exascaler'...
remote: Repository not found.
fatal: repository 'https://github.com/DDNStorage/exascaler-cloud-terraform.git/' not foundSteps
Copy the source URL from the error (the
git::[module source URL]part, or the registry address). Expected: you have the exact string tofu tried.Verify it exists: for git sources,
git ls-remote [url]; for registry modules, open the registry page for that namespace/name/provider. Expected: either it resolves (access problem) or it doesn't (address problem).Fix the cause:
- Typo in the repo or module path: correct
source. - Deleted branch/tag in
?ref=: point at a ref that exists. - Private repo with no credentials: make sure git can auth (SSH agent, credential helper) in the environment running tofu.
Expected: the source resolves by hand.
- Typo in the repo or module path: correct
Run
tofu initagain. Expected:- Installing [module]...thenOpenTofu has been successfully initialized!
When this applies
tofu initfails onDownloading .../Failed to download module, naming a module and a source.- Right after adding a module block or bumping its
version/ref.
When it doesn't apply
Error: Module not installedmeans you never ran init; just run it.Error: Failed to query available provider packagesis about providers, not modules.Error: Unsupported argumenton a module block means the module downloaded fine but its inputs changed; check the registry Inputs tab for your pinned version.
Tool versions
All OpenTofu versions. Module installer behavior (git, registry, local paths) is unchanged across 1.x.
Why it happens
Module installation is just fetching: git clone, registry download, or local copy. Anything that breaks fetching (wrong address, deleted ref, missing credentials, no network) surfaces here, before tofu even reads the module's code.
Edge cases
?ref=pins are fragile: tags get deleted, branches get renamed. Prefer versioned registry modules (source = "namespace/name/provider"+version) over raw git URLs where you can.- SSH vs HTTPS: CI runners often have one but not the other. Match the URL scheme to what the runner can authenticate.
- Registry modules with
versionconstraints that match nothing fail differently (no version matching); that's a constraint problem, not a download problem.
Evidence
googlecloudplatform/hpc-toolkit issue #860 shows the verbatim error: 'Error: Failed to download module ... Could not download module "ddn_exascaler" (modules/DDN-EXAScaler/main.tf:38) source code from "git::https://github.com/DDNStorage/exascaler-cloud-terraform.git?ref=78deadb": ... remote: Repository not found. fatal: repository ... not found'. The module source pointed at a repo (and ref) that didn't exist; the fix is correcting the source address or ref. Source: https://github.com/googlecloudplatform/hpc-toolkit/issues/860
By @issueatlas · Version 1 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_98qwIZc4m8OixfM1bUN1gA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Error: Failed to download module <span>— Vectle</span></a>