louislam/dockge · error · Error
Failed to stop service ${serviceName}, please check logs for
Error message
Failed to stop service ${serviceName}, please check logs for more information. What it means
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.
Source
Thrown at backend/stack.ts:568
return statusList;
}
}
async startService(socket: DockgeSocket, serviceName: string) {
const terminalName = getComposeTerminalName(socket.endpoint, this.name);
const exitCode = await Terminal.exec(this.server, socket, terminalName, "docker", [ "compose", "up", "-d", serviceName ], this.path);
if (exitCode !== 0) {
throw new Error(`Failed to start service ${serviceName}, please check logs for more information.`);
}
return exitCode;
}
async stopService(socket: DockgeSocket, serviceName: string): Promise<number> {
const terminalName = getComposeTerminalName(socket.endpoint, this.name);
const exitCode = await Terminal.exec(this.server, socket, terminalName, "docker", [ "compose", "stop", serviceName ], this.path);
if (exitCode !== 0) {
throw new Error(`Failed to stop service ${serviceName}, please check logs for more information.`);
}
return exitCode;
}
async restartService(socket: DockgeSocket, serviceName: string): Promise<number> {
const terminalName = getComposeTerminalName(socket.endpoint, this.name);
const exitCode = await Terminal.exec(this.server, socket, terminalName, "docker", [ "compose", "restart", serviceName ], this.path);
if (exitCode !== 0) {
throw new Error(`Failed to restart service ${serviceName}, please check logs for more information.`);
}
return exitCode;
}
}
View on GitHub (pinned to f809ae192b)
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
Example fix
// before
await stack.stopService(socket, "api"); // 'api' removed from compose.yml
// after
if (composeFileHasService(stack.path, "api")) {
await stack.stopService(socket, "api");
} else {
await dockerRemoveOrphanContainer("api");
} Defensive patterns
Strategy: validation
Validate before calling
const services = (await exec(`docker compose -f ${stack.path}/compose.yml config --services`)).stdout.split(/\s+/).filter(Boolean);
if (!services.includes(serviceName)) {
throw new Error(`Service '${serviceName}' is not defined; cannot stop`);
} Try / catch
try {
await stack.stopService(socket, serviceName);
} catch (e) {
if (e.message.startsWith("Failed to stop service")) {
const ps = await exec("docker compose ps");
console.error(`stop failed for ${serviceName}; current state:\n${ps.stdout}`);
} else throw e;
} Prevention
- 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`)
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Failed to start service ${serviceName}, please check logs fo
- Failed to restart service ${serviceName}, please check logs
- Failed to deploy, please check the terminal output for more
- Failed to delete, please check the terminal output for more
- Failed to start, please check the terminal output for more i
AI-assisted analysis of louislam/dockge@f809ae192b (2026-08-31).
Data as JSON: /api/errors/59d32ef84dde2290.
Report an issue: GitHub.