{"record":{"id":"540595f6bce72dc4","repo":"Billionmail/BillionMail","slug":"failed-to-restart-rspamd-container-v-540595","errorCode":null,"errorMessage":"failed to restart rspamd container: %v","messagePattern":"failed to restart rspamd container: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/internal/service/domains/domains.go","lineNumber":1002,"sourceCode":"\t\tif strings.HasSuffix(path, \".private\") || strings.HasSuffix(path, \".pub\") {\n\t\t\treturn os.Chmod(path, 0644)\n\t\t}\n\t\treturn nil\n\t})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to change DKIM file permissions: %v\", err)\n\t}\n\n\t// 6. Restart rspamd service\n\tdk, err := docker.NewDockerAPI()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to connect to Docker API: %v\", err)\n\t}\n\tdefer dk.Close()\n\n\terr = dk.RestartContainerByName(ctx, consts.SERVICES.Rspamd)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to restart rspamd container: %v\", err)\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":984,"sourceCodeEnd":1007,"githubUrl":"https://github.com/Billionmail/BillionMail/blob/fc36c76c050c3775c5e899faf7403cf0262d2744/core/internal/service/domains/domains.go#L984-L1007","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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)"],"exampleFix":"// before\nerr = dk.RestartContainerByName(ctx, consts.SERVICES.Rspamd)\n// after\nid, err := dk.FindContainerIDByName(consts.SERVICES.Rspamd)\nif err != nil {\n\treturn fmt.Errorf(\"rspamd container not found: %v\", err)\n}\nif err := dk.RestartContainer(ctx, id); err != nil {\n\treturn fmt.Errorf(\"failed to restart rspamd container: %v\", err)\n}","handlingStrategy":"retry","validationCode":"id, err := dk.FindContainerIDByName(consts.SERVICES.Rspamd)\nif err != nil {\n\treturn fmt.Errorf(\"rspamd container %s not found\", consts.SERVICES.Rspamd)\n}","typeGuard":null,"tryCatchPattern":"err := RepairDKIMSigningConfig(ctx)\nif err != nil && strings.Contains(err.Error(), \"failed to restart rspamd container\") {\n\ttime.Sleep(3 * time.Second)\n\terr = RepairDKIMSigningConfig(ctx) // or retry only the restart step\n}","preventionTips":["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"],"tags":["docker","rspamd","container-restart"],"backgroundTag":"container-restart-failed","analyzedSha":"fc36c76c050c3775c5e899faf7403cf0262d2744","analyzedAt":"2026-09-05T21:28:54.019Z","contentChangedAt":"2026-09-05T21:28:54.019Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}