{"record":{"id":"59d32ef84dde2290","repo":"louislam/dockge","slug":"failed-to-stop-service-servicename-please-chec","errorCode":null,"errorMessage":"Failed to stop service ${serviceName}, please check logs for more information.","messagePattern":"Failed to stop service (.+?), please check logs for more information\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"backend/stack.ts","lineNumber":568,"sourceCode":"            return statusList;\n        }\n    }\n\n    async startService(socket: DockgeSocket, serviceName: string) {\n        const terminalName = getComposeTerminalName(socket.endpoint, this.name);\n        const exitCode = await Terminal.exec(this.server, socket, terminalName, \"docker\", [ \"compose\", \"up\", \"-d\", serviceName ], this.path);\n        if (exitCode !== 0) {\n            throw new Error(`Failed to start service ${serviceName}, please check logs for more information.`);\n        }\n\n        return exitCode;\n    }\n\n    async stopService(socket: DockgeSocket, serviceName: string): Promise<number> {\n        const terminalName = getComposeTerminalName(socket.endpoint, this.name);\n        const exitCode = await Terminal.exec(this.server, socket, terminalName, \"docker\", [ \"compose\", \"stop\", serviceName ], this.path);\n        if (exitCode !== 0) {\n            throw new Error(`Failed to stop service ${serviceName}, please check logs for more information.`);\n        }\n\n        return exitCode;\n    }\n\n    async restartService(socket: DockgeSocket, serviceName: string): Promise<number> {\n        const terminalName = getComposeTerminalName(socket.endpoint, this.name);\n        const exitCode = await Terminal.exec(this.server, socket, terminalName, \"docker\", [ \"compose\", \"restart\", serviceName ], this.path);\n        if (exitCode !== 0) {\n            throw new Error(`Failed to restart service ${serviceName}, please check logs for more information.`);\n        }\n\n        return exitCode;\n    }\n}\n","sourceCodeStart":550,"sourceCodeEnd":584,"githubUrl":"https://github.com/louislam/dockge/blob/f809ae192b571944ad773e9866d3e67064ae8043/backend/stack.ts#L550-L584","documentation":"Stack.stopService() runs `docker compose stop <serviceName>` in the stack directory. A non-zero exit code means docker could not stop the service, so the method throws this error naming the service. The actual docker diagnostic is printed to the attached terminal output.","triggerScenarios":"Calling the stop-service socket action when `docker compose stop <name>` exits non-zero — typically the service name is not defined in the compose file, or docker cannot reach the daemon/containers.","commonSituations":"Service was renamed/removed from compose.yml while the UI still lists the old name; docker daemon stopped or restarted; compose project name mismatch so docker looks in the wrong project; permission issues on the docker socket.","solutions":["Read the terminal output for the docker stop error","Confirm the service name matches the compose file (`docker compose config --services`)","Check `docker ps` to see the container's actual state and project label","Retry after restoring daemon connectivity or correcting the service name"],"exampleFix":"// before\nawait stack.stopService(socket, \"api\"); // 'api' removed from compose.yml\n// after\nif (composeFileHasService(stack.path, \"api\")) {\n  await stack.stopService(socket, \"api\");\n} else {\n  await dockerRemoveOrphanContainer(\"api\");\n}","handlingStrategy":"validation","validationCode":"const services = (await exec(`docker compose -f ${stack.path}/compose.yml config --services`)).stdout.split(/\\s+/).filter(Boolean);\nif (!services.includes(serviceName)) {\n  throw new Error(`Service '${serviceName}' is not defined; cannot stop`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await stack.stopService(socket, serviceName);\n} catch (e) {\n  if (e.message.startsWith(\"Failed to stop service\")) {\n    const ps = await exec(\"docker compose ps\");\n    console.error(`stop failed for ${serviceName}; current state:\\n${ps.stdout}`);\n  } else throw e;\n}","preventionTips":["Verify the service still exists in compose.yml before stopping it","Check `docker compose ps` for the container's real project/name","Ensure the docker daemon is reachable before batch stop operations","Clean up orphaned containers after renaming services (`--remove-orphans`)"],"tags":["docker","docker-compose","service-stop","exit-code"],"backgroundTag":"docker-compose-service-stop-failed","analyzedSha":"f809ae192b571944ad773e9866d3e67064ae8043","analyzedAt":"2026-08-31T19:13:50.919Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}