{"record":{"id":"e0ee5fba1a624146","repo":"kopia/kopia","slug":"can-t-connect-to-storage-e0ee5f","errorCode":null,"errorMessage":"can't connect to storage","messagePattern":"can't connect to storage","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command_repository_repair.go","lineNumber":38,"sourceCode":"\nfunc (c *commandRepositoryRepair) setup(svc advancedAppServices, parent commandParent) {\n\tcmd := parent.Command(\"repair\", \"DEPRECATED: Recover format blob from older-format packs.\").Hidden()\n\n\tcmd.Flag(\"recover-format\", \"Recover format blob from a copy\").Default(\"auto\").EnumVar(&c.repairCommandRecoverFormatBlob, \"auto\", \"yes\", \"no\")\n\tcmd.Flag(\"recover-format-block-prefixes\", \"Prefixes of file names\").StringsVar(&c.repairCommandRecoverFormatBlobPrefixes)\n\tcmd.Flag(\"dry-run\", \"Do not modify repository\").Short('n').BoolVar(&c.repairDryRun)\n\n\tfor _, prov := range svc.storageProviders() {\n\t\tf := prov.NewFlags()\n\t\tcc := cmd.Command(prov.Name, \"Repair repository in \"+prov.Description).Hidden()\n\t\tf.Setup(svc, cc)\n\t\tcc.Action(func(kpc *kingpin.ParseContext) error {\n\t\t\tsvc.dangerousCommand()\n\n\t\t\treturn svc.runAppWithContext(kpc.SelectedCommand, func(ctx context.Context) error {\n\t\t\t\tst, err := f.Connect(ctx, false, 0)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn errors.Wrap(err, \"can't connect to storage\")\n\t\t\t\t}\n\n\t\t\t\treturn c.runRepairCommandWithStorage(ctx, st)\n\t\t\t})\n\t\t})\n\t}\n}\n\nfunc packBlockPrefixes() []string {\n\tvar str []string\n\n\tfor _, p := range content.PackBlobIDPrefixes {\n\t\tstr = append(str, string(p))\n\t}\n\n\treturn str\n}\n","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/kopia/kopia/blob/82495e54b584c1ef6073c9e1be048f57f8aef078/cli/command_repository_repair.go#L20-L56","documentation":"`kopia repository repair` connects to the underlying blob storage (via the provided storage flags) before attempting recovery, using f.Connect(ctx, false, 0). If the storage backend cannot be reached or authenticated, the connection error is wrapped with \"can't connect to storage\". This is a pre-repository-layer failure: the raw blob storage itself is inaccessible.","triggerScenarios":"Running `kopia repository repair` with incorrect/missing storage credentials or endpoint flags, network outage to the blob store, wrong bucket/container name, or a provider returning auth errors so f.Connect cannot establish a storage session.","commonSituations":"Typo in --s3-bucket/--s3-endpoint or filesystem path during disaster recovery; expired cloud credentials (S3 keys, GCS/Azure tokens); DNS or firewall blocking the storage endpoint; repairing after the provider region changed.","solutions":["Read the wrapped cause (errors.Cause) to see the provider-specific failure (auth, DNS, not-found).","Verify all storage connection flags (endpoint, bucket/container, credentials) with `kopia repository repair --help` and re-run.","Test connectivity independently, e.g. `kopia repository create s3 --dry-run` or aws/gcloud CLI listing the bucket.","Fix/refresh credentials (env vars, ~/.kopia credentials, cloud IAM) and retry the repair command."],"exampleFix":"// before\nst, err := f.Connect(ctx, false, 0)\nif err != nil {\n\treturn errors.Wrap(err, \"can't connect to storage\")\n}\n// after\nst, err := f.Connect(ctx, false, 0)\nif err != nil {\n\treturn errors.Wrap(err, \"can't connect to storage\") // check flags: kopia repository repair --file-system-path=...\n}","handlingStrategy":"validation","validationCode":"// Go: preflight connectivity before running repair\nctx, cancel := context.WithTimeout(ctx, 30*time.Second)\ndefer cancel()\nif _, err := f.Connect(ctx, false, 0); err != nil {\n\treturn fmt.Errorf(\"storage unreachable, fix flags/credentials before repair: %w\", err)\n}","typeGuard":"// Go: nil-check the returned storage before use\nst, err := f.Connect(ctx, false, 0)\nif err != nil || st == nil {\n\treturn errors.Wrap(err, \"can't connect to storage\")\n}","tryCatchPattern":"st, err := f.Connect(ctx, false, 0)\nif err != nil {\n\treturn errors.Wrap(err, \"can't connect to storage\") // surface errors.Cause to the user with flag guidance\n}","preventionTips":["Verify storage flags (endpoint, bucket, credentials) with a cheap listing call before repair.","Use long-lived credentials for disaster-repair operations to avoid mid-run auth expiry.","Test network/DNS access to the storage endpoint from the repair host.","Keep a copy of the original repository connect info alongside backups."],"tags":["kopia","storage","connectivity","cli"],"backgroundTag":"connection-refused","analyzedSha":"82495e54b584c1ef6073c9e1be048f57f8aef078","analyzedAt":"2026-09-07T20:35:21.689Z","contentChangedAt":"2026-09-07T20:35:21.689Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}