microsoft/playwright · error · Error
Could not start the session "${sessionName}"
Error message
Could not start the session "${sessionName}" What it means
Thrown by Registry.loadEntry when Registry._loadSessionEntry returns no entry for the requested session file (sessionName + '.session' could not be read/parsed from the daemon profiles dir). It means the named session does not exist or its file is unreadable.
Source
Thrown at packages/playwright-core/src/tools/cli-client/registry.ts:85
entry(clientInfo: ClientInfo, sessionName: string): SessionFile | undefined {
const key = clientKey(clientInfo);
const entries = this._files.get(key) || [];
return entries.find(entry => entry.config.name === sessionName);
}
entries(clientInfo: ClientInfo): SessionFile[] {
return this._files.get(clientKey(clientInfo)) || [];
}
entryMap(): Map<string, SessionFile[]> {
return this._files;
}
async loadEntry(clientInfo: ClientInfo, sessionName: string): Promise<SessionFile> {
const entry = await Registry._loadSessionEntry(clientInfo.daemonProfilesDir, sessionName + '.session');
if (!entry)
throw new Error(`Could not start the session "${sessionName}"`);
const key = clientKey(clientInfo);
let list = this._files.get(key);
if (!list) {
list = [];
this._files.set(key, list);
}
const oldIndex = list.findIndex(e => e.config.name === sessionName);
if (oldIndex !== -1)
list.splice(oldIndex, 1);
list.push(entry);
return entry;
}
private static async _loadSessionEntry(daemonDir: string, file: string): Promise<SessionFile | undefined> {
try {
const fileName = path.join(daemonDir, file);
const data = await fs.promises.readFile(fileName, 'utf-8');View on GitHub (pinned to c8fc3bf8d3)
Solutions
- Create the session first with: playwright-cli -s=<name> open.
- Verify the session file exists under the daemon profiles dir (clientInfo.daemonProfilesDir).
- Drop the -s flag to operate on the 'default' session, or list sessions to confirm the name.
Example fix
# before playwright-cli -s=ci screenshot # session 'ci' missing -> throws # after playwright-cli -s=ci open # create/launch the session playwright-cli -s=ci screenshot # now works
Defensive patterns
Strategy: validation
Validate before calling
import fs from 'fs';
import path from 'path';
function sessionExists(daemonProfilesDir: string, name: string): boolean {
return fs.existsSync(path.join(daemonProfilesDir, name + '.session'));
}
if (!sessionExists(info.daemonProfilesDir, name)) {
// run `playwright-cli -s=<name> open` instead of failing Type guard
function isMissingSessionError(e: unknown): boolean {
return e instanceof Error && e.message.startsWith('Could not start the session');
} Try / catch
try {
await session.run(clientInfo, args);
} catch (e) {
if (isMissingSessionError(e)) {
await Session.startDaemon(clientInfo, { session: name } as any, 'open');
await session.run(clientInfo, args); // retry after open
} else throw e;
} Prevention
- Ensure `playwright-cli -s=<name> open` has been run before issuing commands.
- When distributing across machines, recreate the session per machine rather than copying files.
When it happens
Trigger: Calling a session-scoped command (e.g. playwright-cli -s=myname <cmd>) when 'myname' has never been opened, was deleted, or its .session file is corrupt.
Common situations: Typo in the -s flag; running on a different machine / user account where the daemon profiles dir has no such session; the session file was hand-deleted; downgrading left the file unreadable.
Related errors
- Client is v${clientInfo.version}, session '${this.name}' is
- Browser '${this.name}' is not open. Run playwright-cli${t
- --data must be in "mime/type=value" format, got: ${entry}
- Command is required
- No trace opened. Run 'npx playwright trace open <file>' firs
AI-assisted analysis of microsoft/playwright@c8fc3bf8d3 (2026-08-12).
Data as JSON: /api/errors/db90ddd98db3b954.
Report an issue: GitHub.