louislam/dockge · error · Error

Failed to restart service ${serviceName}, please check logs

Error message

Failed to restart service ${serviceName}, please check logs for more information.

What it means

Stack.restartService() runs `docker compose restart <serviceName>` in the stack directory and throws this error when the command exits non-zero. The message names the service; the root-cause output (daemon errors, unknown service, container create failures) is in the terminal stream.

Source

Thrown at backend/stack.ts:578

        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

  1. Check the terminal output for the docker restart error
  2. Verify the container exists: `docker compose ps` in the stack directory
  3. If the container was removed, use `docker compose up -d <service>` instead of restart
  4. Confirm the service name against the current compose file and retry

Example fix

// before
await stack.restartService(socket, "db"); // container was removed, restart fails
// after
if (await serviceContainerExists(stack.path, "db")) {
  await stack.restartService(socket, "db");
} else {
  await stack.startService(socket, "db"); // recreate via up -d
}
Defensive patterns

Strategy: validation

Validate before calling

const ps = await exec(`docker compose -f ${stack.path}/compose.yml ps -q ${serviceName}`);
if (!ps.stdout.trim()) {
  // container does not exist; use up -d instead of restart
  await stack.startService(socket, serviceName);
} else {
  await stack.restartService(socket, serviceName);
}

Try / catch

try {
  await stack.restartService(socket, serviceName);
} catch (e) {
  if (e.message.startsWith("Failed to restart service")) {
    await stack.startService(socket, serviceName); // fallback: recreate via up -d
  } else throw e;
}

Prevention

When it happens

Trigger: Calling the restart-service socket action when `docker compose restart <name>` exits non-zero — service not defined in the compose file, no such container running, or docker daemon unavailable.

Common situations: Restarting a service whose container was removed (docker compose restart only works on existing containers); compose file edited so the service name no longer matches; docker daemon restart left the container in a bad state.

Related errors


AI-assisted analysis of louislam/dockge@f809ae192b (2026-08-31). Data as JSON: /api/errors/027030ce7c3aea07. Report an issue: GitHub.