hashicorp/nomad · error

could not configure eventlog - %w

Error message

could not configure eventlog - %w

What it means

Wraps the failure of `srvc.EnableEventlog`, which registers the Nomad service in the Windows Event Log so agent logs are attributed to it. The underlying registry/EventLog configuration error is chained with %w.

Source

Thrown at command/windows_service_install.go:231

		}
	} else {
		srvc, err = m.CreateService(winsvc.WINDOWS_SERVICE_NAME, opts.binaryPath,
			winsvc.WindowsServiceConfiguration{
				StartType:      winsvc.StartAutomatic,
				DisplayName:    winsvc.WINDOWS_SERVICE_DISPLAY_NAME,
				Description:    winsvc.WINDOWS_SERVICE_DESCRIPTION,
				BinaryPathName: cmd,
			},
		)
		if err != nil {
			return fmt.Errorf("unable to create service - %w", err)
		}
		defer srvc.Close()
	}

	// Enable the service in the Windows eventlog
	if err := srvc.EnableEventlog(); err != nil {
		return fmt.Errorf("could not configure eventlog - %w", err)
	}

	// Ensure the service is stopped
	if err := srvc.Stop(); err != nil {
		return fmt.Errorf("could not stop service - %w", err)
	}

	// Start the service so the new binary is in use
	if err := srvc.Start(); err != nil {
		return fmt.Errorf("could not start service - %w", err)
	}

	return nil
}

func (c *WindowsServiceInstallCommand) configInstall(opts *windowsInstallOpts) error {
	// If the config or data directory are unset, default them
	if opts.configDir == "" {

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Re-run the install from an elevated shell
  2. Check permissions on HKLM\SYSTEM\CurrentControlSet\Services\EventLog\Application
  3. Temporarily exclude Nomad install paths from security software and retry
  4. Verify group policy isn't locking the EventLog registry key

Example fix

// before
PS> nomad windows install
// after
PS (admin)> nomad windows install
Defensive patterns

Strategy: try-catch

Validate before calling

key, err := registry.OpenKey(registry.LOCAL_MACHINE,
	`SYSTEM\CurrentControlSet\Services\EventLog\Application`, registry.SET_VALUE)
if err != nil {
	log.Fatalf("no write access to EventLog registry key (run elevated): %v", err)
}
key.Close()

Try / catch

if err := srvc.EnableEventlog(); err != nil {
	if errors.Is(err, registry.ErrShortBuffer) || errors.Is(err, windows.ERROR_ACCESS_DENIED) {
		// elevate and retry
	}
	return fmt.Errorf("could not configure eventlog - %w", err)
}

Prevention

When it happens

Trigger: Adding the EventLog message-file registry entry (HKLM\SYSTEM\CurrentControlSet\Services\EventLog\Application) fails: access denied, registry locked by policy, or registry virtualization issues.

Common situations: Non-elevated run blocked from writing HKLM; group policy restricting registry edits; antivirus blocking registry writes to the EventLog key.

Related errors


AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04). Data as JSON: /api/errors/07e5263b278a79cd. Report an issue: GitHub.