kopia/kopia · error

cannot open storage

Error message

cannot open storage

What it means

openDirect failed to instantiate the blob storage backend described in the repository config file: blob.NewStorage returned an error. This means the provider (filesystem, S3, B2, GCS, azure, sftp, rclone, webdav...) could not be constructed or connected — wrong credentials, unreachable endpoint, or unsupported/unknown provider type. No repository can be opened without storage.

Solutions

  1. Inspect the wrapped cause for the provider-specific failure (auth, network, path)
  2. Run `kopia repository set-client` / re-run `kopia connect <provider>` to regenerate storage config with valid parameters
  3. Verify credentials, endpoints, bucket/container names, and local paths in kopia.config.json
  4. Test the backend independently (aws s3 ls, az storage blob list, curl the endpoint) to isolate connectivity
  5. Confirm the storage Type is one supported by your Kopia build/version

Example fix

// before
"storage": {"type": "s3", "config": {"bucket": "my-backups", "accessKeyID": "OLDKEY"}}
// after: reconnect to refresh credentials
// $ kopia repository connect s3 --bucket=my-backups --access-key=NEWKEY --secret-access-key=...
Defensive patterns

Strategy: validation

Validate before calling

// validate storage config before opening
if cfg.Storage == nil || cfg.Storage.Type == "" {
    return errors.New("storage not configured")
}
if cfg.Storage.Type == "filesystem" {
    if _, err := os.Stat(cfg.Storage.Path); err != nil {
        return fmt.Errorf("storage path missing: %w", err)
    }
}

Try / catch

st, err := blob.NewStorage(ctx, *lc.Storage, false)
if err != nil {
    return fmt.Errorf("cannot open storage (check credentials/endpoint for %q): %w", lc.Storage.Type, err)
}

Prevention

When it happens

Trigger: `kopia repository connect`/`open` where lc.Storage in the config references a backend whose parameters fail: bad access keys, nonexistent local path, unknown Type string, unreachable endpoint, or invalid TLS settings.

Common situations: S3 credentials expired or wrong region; filesystem path deleted/moved; config file edited by hand with an unknown provider type; network/firewall blocking the object store; provider plugin removed in a newer Kopia version.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of kopia/kopia@82495e54b5 (2026-09-07). Data as JSON: /api/errors/41cfb09dcd6fba2c. Report an issue: GitHub.

Appendix: source

Thrown at repo/open.go:232

	}

	// close on error to avoid leaking ref-counted resources
	if err2 := par.Close(ctx); err2 != nil {
		err = stderrors.Join(err, err2)
	}

	return nil, err
}

// openDirect opens the repository that directly manipulates blob storage..
func openDirect(ctx context.Context, configFile string, lc *LocalConfig, password string, options *Options) (rep Repository, err error) {
	if lc.Storage == nil {
		return nil, errors.New("storage not set in the configuration file")
	}

	st, err := blob.NewStorage(ctx, *lc.Storage, false)
	if err != nil {
		return nil, errors.Wrap(err, "cannot open storage")
	}

	if lc.ReadOnly {
		st = readonly.NewWrapper(st)
	}

	cliOpts := lc.ApplyDefaults(ctx, "Repository in "+st.DisplayName())

	r, err := openWithConfig(ctx, st, cliOpts, password, options, lc.Caching, configFile)
	if err != nil {
		st.Close(ctx) //nolint:errcheck
		return nil, err
	}

	return r, nil
}

// openWithConfig opens the repository with a given configuration, avoiding the need for a config file.

View on GitHub (pinned to 82495e54b5)