# Terraform: Error: Failed to download module — Could not download module "vpc" (main.tf:1) source code from "git::https://github.com/org/repo.git": error downloading

**Code:** `Failed to download module (git/registry/path)` · **Category:** Terraform · **Seen on:** Terraform, Git

Terraform couldn't fetch a module's source (git auth, wrong ref/path, registry, network).

## Meaning

Check the source URL, ref (`?ref=v1.2.3`), credentials (SSH key or token for private repos: `git config --global url."https://x:TOKEN@github.com/".insteadOf "https://github.com/"` or SSH `git::ssh://git@github.com/org/repo.git`), subdirectory syntax (`//modules/x`), and Terraform registry version constraints. `terraform init` output has the underlying git error.

## Common causes

- Private repo without credentials
- Wrong tag/ref or subdir path
- Registry module/version not found
- Network/proxy issues
- SSH key not available in CI

## Quick fix

1. Test with `git ls-remote URL`
2. Use correct `?ref=` and `//subdir` syntax
3. Configure git credentials/SSH agent in CI

## Detailed fix by platform

### Linux

1. `git ls-remote https://github.com/org/repo.git v1.2.3`

## How to diagnose

1. **Source** — URL/ref?
2. **Auth** — Credentials?
3. **Path** — Subdir syntax?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/terraform/failed-to-download-module)
