angular/angular-cli · error · Error
Dev server already started.
Error message
Dev server already started.
What it means
The MCP devserver manager in @angular/cli throws this plain Error from start() when a Devserver instance already has a child process running. It guards against launching a second `ng serve` process from the same Devserver object, since each instance owns exactly one dev-server process.
Source
Thrown at packages/angular/cli/src/commands/mcp/devserver.ts:111
host,
port,
workspacePath,
project,
}: {
host: Host;
port: number;
workspacePath: string;
project: string;
}) {
this.host = host;
this.port = port;
this.workspacePath = workspacePath;
this.project = project;
}
start() {
if (this.devserverProcess) {
throw Error('Dev server already started.');
}
const args = ['serve'];
if (this.project) {
args.push(this.project);
}
args.push(`--port=${this.port}`);
this.devserverProcess = this.host.startNgProcess(args, {
stdio: 'pipe',
cwd: this.workspacePath,
});
processStreamLines(this.devserverProcess.stdout, (line) => this.addLog(line));
processStreamLines(this.devserverProcess.stderr, (line) => this.addLog(line));
this.devserverProcess.on('close', () => {
this.stop();View on GitHub (pinned to bb72145f9a)
Solutions
- Call devserver.stop() (or the devserver-stop MCP tool) before starting again.
- Check whether a server is already running (list current devservers / track the instance) and reuse it instead of calling start().
- Wrap start() in a check or try-catch and treat this message as an idempotent 'already running' signal.
- Create a fresh Devserver instance for a different workspace/project instead of reusing the existing one.
Example fix
// before
const server = new Devserver({ workspacePath, project });
server.start();
server.start(); // throws 'Dev server already started.'
// after
const server = new Devserver({ workspacePath, project });
if (!server.isRunning()) server.start(); Defensive patterns
Strategy: try-catch
Validate before calling
if (!server.isRunning?.()) {
server.start();
} Type guard
function isAlreadyStartedError(err: unknown): err is Error {
return err instanceof Error && err.message === 'Dev server already started.';
} Try / catch
try {
server.start();
} catch (err) {
if (!isAlreadyStartedError(err)) throw err;
// already running: reuse the existing devserver
} Prevention
- Track whether a Devserver instance was already started before invoking start().
- Treat devserver-start as idempotent: on this error, reuse the running server.
- Always pair start with stop in teardown logic.
- Use the MCP devserver-stop tool before re-running devserver-start.
When it happens
Trigger: Calling Devserver.start() twice on the same instance without calling stop() in between — e.g. the MCP client invokes the devserver-start tool twice, or start() is retried after a first successful launch while this.devserverProcess is still set.
Common situations: An MCP agent re-issues a devserver-start tool call because it assumed the previous one failed; automation scripts starting the server on each request; forgetting that the server persists across tool calls within one MCP session.
Related errors
- Dev server not found. Currently running servers: ${runningSe
- Dev server not found. Currently running servers: ${runningSe
- Workspace path is outside the allowed MCP roots: ${workspace
- Watch mode execution (serve target or watch option) is not y
- Workspace path is outside the allowed MCP roots: ${workspace
AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30).
Data as JSON: /api/errors/3e831a8d5de82db9.
Report an issue: GitHub.