netbirdio/netbird · warning

save service params: %w

Error message

save service params: %w

What it means

saveServiceParams could not persist install parameters. WriteJsonWithRestrictedPermission creates the parent directory, enforces restrictive permissions, then writes via temp file plus rename; the wrap carries whichever step failed. CLI callers only print a warning, so the service itself is usually still installed.

Source

Thrown at client/cmd/service_params.go:70

			return nil, nil //nolint:nilnil
		}
		return nil, fmt.Errorf("read service params %s: %w", path, err)
	}

	var params serviceParams
	if err := json.Unmarshal(data, &params); err != nil {
		return nil, fmt.Errorf("parse service params %s: %w", path, err)
	}

	return &params, nil
}

// saveServiceParams writes current service parameters to disk atomically
// with restricted permissions.
func saveServiceParams(params *serviceParams) error {
	path := serviceParamsPath()
	if err := util.WriteJsonWithRestrictedPermission(context.Background(), path, params); err != nil {
		return fmt.Errorf("save service params: %w", err)
	}
	return nil
}

// currentServiceParams captures the current state of all package-level
// variables into a serviceParams struct.
func currentServiceParams() *serviceParams {
	params := &serviceParams{
		LogLevel:              logLevel,
		DaemonAddr:            daemonAddr,
		JSONSocket:            jsonSocket,
		ManagementURL:         managementURL,
		ConfigPath:            configPath,
		LogFiles:              logFiles,
		DisableProfiles:       profilesDisabled,
		DisableUpdateSettings: updateSettingsDisabled,
		EnableCapture:         captureEnabled,
		DisableNetworks:       networksDisabled,

View on GitHub (pinned to 93e97f4bf1)

Solutions

  1. Run install/reinstall elevated so the state dir is writable
  2. Fix the state dir: sudo mkdir -p /var/lib/netbird && sudo chown root:root /var/lib/netbird
  3. Free disk space and remount read-only mounts read-write
  4. Retry the save via a reconfigure once the directory is fixed
Defensive patterns

Strategy: validation

Validate before calling

dir := filepath.Dir(serviceParamsPath())
if err := os.MkdirAll(dir, 0o750); err != nil {
	return fmt.Errorf("state dir %s not writable: %w", dir, err)
}
if f, err := os.CreateTemp(dir, ".probe"); err != nil {
	return fmt.Errorf("state dir %s not writable: %w", dir, err)
} else {
	_ = f.Close()
	_ = os.Remove(f.Name())
}

Try / catch

if err := saveServiceParams(currentServiceParams()); err != nil {
	// callers only warn: the install itself succeeded
	cmd.PrintErrf("Warning: failed to save service params: %v\n", err)
}

Prevention

When it happens

Trigger: State directory not writable (non-root run after root owned /var/lib/netbird); the permission-enforcement chmod failing; rename blocked by the filesystem; disk full.

Common situations: Running install/reconfigure with partial privileges; read-only or network-mounted state dirs; Windows ACL inheritance blocking the permission step.

Related errors


AI-assisted analysis of netbirdio/netbird@93e97f4bf1 (2026-08-16). Data as JSON: /api/errors/ad00a9f8e303d1f4. Report an issue: GitHub.