Billionmail/BillionMail · error
failed to restart rspamd container: %v
Error message
failed to restart rspamd container: %v
What it means
The rspamd container restart via the Docker API failed. RestartContainerByName issues a stop/start (or restart) on the container named consts.SERVICES.Rspamd; any API-level failure (container missing, daemon error, timeout) is wrapped here.
Source
Thrown at core/internal/service/domains/domains.go:1002
if strings.HasSuffix(path, ".private") || strings.HasSuffix(path, ".pub") {
return os.Chmod(path, 0644)
}
return nil
})
if err != nil {
return fmt.Errorf("failed to change DKIM file permissions: %v", err)
}
// 6. Restart rspamd service
dk, err := docker.NewDockerAPI()
if err != nil {
return fmt.Errorf("failed to connect to Docker API: %v", err)
}
defer dk.Close()
err = dk.RestartContainerByName(ctx, consts.SERVICES.Rspamd)
if err != nil {
return fmt.Errorf("failed to restart rspamd container: %v", err)
}
return nil
}
View on GitHub (pinned to fc36c76c05)
Solutions
- Run `docker ps` and confirm the actual rspamd container name matches consts.SERVICES.Rspamd
- If the container is managed by compose, restart it by ID lookup (docker ps -q filter) instead of a hardcoded name
- Check rspamd logs for crash loops preventing restart
- Inspect the wrapped %v error for API-level cause (404 vs timeout)
Example fix
// before
err = dk.RestartContainerByName(ctx, consts.SERVICES.Rspamd)
// after
id, err := dk.FindContainerIDByName(consts.SERVICES.Rspamd)
if err != nil {
return fmt.Errorf("rspamd container not found: %v", err)
}
if err := dk.RestartContainer(ctx, id); err != nil {
return fmt.Errorf("failed to restart rspamd container: %v", err)
} Defensive patterns
Strategy: retry
Validate before calling
id, err := dk.FindContainerIDByName(consts.SERVICES.Rspamd)
if err != nil {
return fmt.Errorf("rspamd container %s not found", consts.SERVICES.Rspamd)
} Try / catch
err := RepairDKIMSigningConfig(ctx)
if err != nil && strings.Contains(err.Error(), "failed to restart rspamd container") {
time.Sleep(3 * time.Second)
err = RepairDKIMSigningConfig(ctx) // or retry only the restart step
} Prevention
- Verify container names match the compose deployment (project prefixes)
- Check rspamd isn't crash-looping before restarting
- Use container ID lookups instead of hardcoded names
- Add a short retry with backoff for transient daemon timeouts
When it happens
Trigger: RestartContainerByName(ctx, consts.SERVICES.Rspamd) returns non-nil: the rspamd container name doesn't match (custom compose project prefix), the container is stopped/removed, the Docker daemon rejects the restart, or the request times out.
Common situations: consts.SERVICES.Rspamd hardcodes a name but docker-compose prefixes containers (e.g. billionmail-rspamd-1); rspamd crash-looping so restart fails; daemon under load or socket timeout during heavy IO.
Related errors
- failed to restart postfix container: %v
- Failed to generate DKIM key pair: %v
- Failed to restart rspamd container: %v
- rspamdadm not found
- failed to list containers: %w
AI-assisted analysis of Billionmail/BillionMail@fc36c76c05 (2026-09-05).
Data as JSON: /api/errors/540595f6bce72dc4.
Report an issue: GitHub.