caddyserver/caddy · error

unable to open root directory %s: %w

Error message

unable to open root directory %s: %w

What it means

Error "unable to open root directory %s: %w" thrown in caddyserver/caddy.

Source

Thrown at modules/caddytls/folderloader.go:68

	if !ok {
		repl = caddy.NewReplacer()
	}
	for k, path := range fl {
		fl[k] = repl.ReplaceKnown(path, "")
	}
	return nil
}

// LoadCertificates loads all the certificates+keys in the directories
// listed in fl from all files ending with .pem. This method of loading
// certificates expects the certificate and key to be bundled into the
// same file.
func (fl FolderLoader) LoadCertificates() ([]Certificate, error) {
	var certs []Certificate
	for _, dir := range fl {
		root, err := os.OpenRoot(dir)
		if err != nil {
			return nil, fmt.Errorf("unable to open root directory %s: %w", dir, err)
		}
		err = filepath.WalkDir(dir, func(fpath string, d fs.DirEntry, err error) error {
			if err != nil {
				return fmt.Errorf("unable to traverse into path: %s", fpath)
			}
			if d.IsDir() {
				return nil
			}
			if !strings.HasSuffix(strings.ToLower(d.Name()), ".pem") {
				return nil
			}

			rel, err := filepath.Rel(dir, fpath)
			if err != nil {
				return fmt.Errorf("unable to get relative path for %s: %w", fpath, err)
			}

			bundle, err := root.ReadFile(rel)

View on GitHub (pinned to 50e54ee279)

Solutions

  1. Check that the root directory exists and is readable by the Caddy process.

When it happens

Trigger: Thrown at modules/caddytls/folderloader.go:68 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of caddyserver/caddy@50e54ee279 (2026-08-15). Data as JSON: /api/errors/9452acc0d76d2794. Report an issue: GitHub.