vitest-dev/vitest · error · Error
Can't find browser origin URL for project
Error message
Can't find browser origin URL for project "${this.name}" What it means
After confirming the browser is initialized, _openBrowserPage reads this.browser.vite.resolvedUrls to find the local or network origin. If neither local[0] nor network[0] exists, there is no URL to build the test page address from, so it throws naming the project.
Solutions
- Check the Vite dev server startup logs for bind/listen errors.
- Ensure server.host/port config is valid and the port is not already in use.
- Avoid custom plugins that override resolvedUrls or server.listen behavior.
- Retry after the server is fully ready; if persistent, file an issue with the server config.
Defensive patterns
Strategy: validation
Validate before calling
// Ensure the dev server produced URLs before opening pages.
function assertOrigin(urls: { local?: string[]; network?: string[] } | null | undefined) {
const origin = urls?.local?.[0] ?? urls?.network?.[0]
if (!origin) throw new Error('Browser dev server has no resolved URL; check server config / port.')
return origin
} Type guard
const hasResolvedUrl = (urls: { local?: string[]; network?: string[] } | null | undefined): boolean =>
Boolean(urls && (urls.local?.length || urls.network?.length)) Prevention
- Verify the Vite dev server binds successfully (check ports).
- Avoid plugins that override resolvedUrls or server.listen.
- Wait for server ready before triggering browser page open.
When it happens
Trigger: The browser Vite server has no resolvedUrls (local/network both empty) when _openBrowserPage tries to construct the /__vitest_test__/ page URL.
Common situations: The dev server failed to bind/resolve URLs, a custom server config that suppresses resolvedUrls, the server starting in a mode that does not compute URLs, or a race reading resolvedUrls before server.listen finished.
Related errors
- Browser is not initialized
- browser is not initialized
- Cannot spawn child server without a parent dev server.
- Access denied to " ". See Vite config documentation for…
- All browser instances within a project must use the same…
AI-assisted analysis of vitest-dev/vitest@1fa9837ec2 (2026-08-11).
Data as JSON: /api/errors/7e3aa7aa474873a1.
Report an issue: GitHub.
Appendix: source
Thrown at packages/vitest/src/node/project.ts:484
/** @internal */
public _getViteEnvironments(): DevEnvironment[] {
return Object.values(this.vite.environments || {})
}
/** @internal */
public async _openBrowserPage(sessionId: string, pool: {
reject: (error: Error) => void
parallel?: boolean
}): Promise<void> {
if (!this.browser) {
throw new Error(`browser is not initialized`)
}
const resolvedUrls = this.browser.vite.resolvedUrls
const origin = resolvedUrls?.local[0] ?? resolvedUrls?.network[0]
if (!origin) {
throw new Error(
`Can't find browser origin URL for project "${this.name}"`,
)
}
const url = new URL('/__vitest_test__/', origin)
url.searchParams.set('sessionId', sessionId)
const otelCarrier = this.vitest._traces.getContextCarrier()
this.vitest._browserSessions.sessionIds.add(sessionId)
const sessionPromise = this.vitest._browserSessions.createSession(
sessionId,
this,
pool,
{ otelCarrier },
)
const pagePromise = this.browser.provider.openPage(
sessionId,
url.toString(),
{ parallel: pool.parallel ?? false },View on GitHub (pinned to 1fa9837ec2)