AdguardTeam/AdGuardHome · error
restarting service: %w
Error message
restarting service: %w
What it means
The service manager was created, but performing the Restart action on the AdGuard Home service failed. svcMgr.Perform wraps platform-specific errors from systemd/svc control commands.
Source
Thrown at internal/home/service.go:140
// restartService restarts the service. It returns error if the service is not
// running. l must not be nil.
func restartService(ctx context.Context, baseLogger *slog.Logger) (err error) {
svcMgr, err := ossvc.NewManager(ctx, &ossvc.ManagerConfig{
Clock: timeutil.SystemClock{},
Logger: baseLogger.With(slogutil.KeyPrefix, svcLogPrefix),
CommandConstructor: executil.SystemCommandConstructor{},
})
if err != nil {
return fmt.Errorf("initializing service manager: %w", err)
}
act := &ossvc.ActionRestart{
ServiceName: serviceName,
}
err = svcMgr.Perform(ctx, act)
if err != nil {
return fmt.Errorf("restarting service: %w", err)
}
return nil
}
// handleServiceControlAction one of the possible control actions:
//
// - install: Installs a service/daemon.
// - uninstall: Uninstalls it.
// - status: Prints the service status.
// - start: Starts the previously installed service.
// - stop: Stops the previously installed service.
// - restart: Restarts the previously installed service.
// - run: This is a special command that is not supposed to be used directly
// it is specified when we register a service, and it indicates to the app
// that it is being run as a service/daemon.
func handleServiceControlAction(
ctx context.Context,View on GitHub (pinned to b41aefbe51)
Solutions
- Run the update/restart as root or with sudo
- Verify the service exists and is running: systemctl status AdGuardHome
- In containers, skip service-based restart; restart the container instead
Example fix
# before ./AdGuardHome --update # after sudo ./AdGuardHome --update
Defensive patterns
Strategy: try-catch
Validate before calling
// Check service state before restart:
if st, _ := svcMgr.Status(ctx, name); st != svc.StatusRunning { /* handle */ } Try / catch
if err := svcMgr.Perform(ctx, act); err != nil {
return fmt.Errorf("restarting service: %w", err) // distinguish EPERM vs not-found in logs
} Prevention
- Run updates with sudo/root
- Keep systemd unit files managed by the installer, not hand-edited
When it happens
Trigger: cmdlineUpdate → restartService → svcMgr.Perform(ActionRestart) failing due to the service being stopped already, insufficient privileges (not root), or the service manager timing out.
Common situations: Running 'AdGuardHome --update' as a non-root user, D-Bus/systemd unavailable in containers, or the unit file having been removed manually.
Related errors
- action %q: %w
- initializing service: %w
- initializing service manager: %w
- getting current directory: %w
- %w: %q
AI-assisted analysis of AdguardTeam/AdGuardHome@b41aefbe51 (2026-08-27).
Data as JSON: /api/errors/75a4500bcf0326cc.
Report an issue: GitHub.