n8n-io/n8n · error · Error

Failed to authenticate with n8n — no session cookie received

Error message

Failed to authenticate with n8n — no session cookie received

What it means

N8nClient.login POSTs to /rest/login with email/password and then inspects the response for an `n8n-auth` cookie. If no session cookie was set, login did not actually authenticate (wrong creds, instance misconfigured, or cookie not returned) and the client cannot make authenticated calls.

Source

Thrown at packages/@n8n/instance-ai/evaluations/clients/n8n-client.ts:225

	// -- Auth ----------------------------------------------------------------

	/**
	 * Authenticate with the n8n instance via POST /rest/login.
	 * Captures the `n8n-auth` cookie for subsequent requests.
	 */
	async login(email?: string, password?: string): Promise<void> {
		// Defaults match the E2E test owner created by the E2E_TESTS=true bootstrap
		const loginEmail = email ?? process.env.N8N_EVAL_EMAIL ?? 'nathan@n8n.io';
		const loginPassword = password ?? process.env.N8N_EVAL_PASSWORD ?? 'PlaywrightTest123';

		await this.fetch('/rest/login', {
			method: 'POST',
			body: { emailOrLdapLoginId: loginEmail, password: loginPassword },
		});

		if (!this.sessionCookie) {
			throw new Error('Failed to authenticate with n8n — no session cookie received');
		}
	}

	// -- Instance-AI endpoints -----------------------------------------------

	/**
	 * Ensure a conversation thread exists before sending chat messages.
	 * POST /rest/instance-ai/threads body: { threadId, projectId, source }
	 */
	async ensureThread(threadId: string, projectId?: string): Promise<void> {
		const resolvedProjectId = projectId ?? (await this.getPersonalProjectId());
		await this.fetch('/rest/instance-ai/threads', {
			method: 'POST',
			body: {
				threadId,
				projectId: resolvedProjectId,
				source: 'evals',
				origin: 'internal',

View on GitHub (pinned to 5ac6606e81)

Solutions

  1. Verify the credentials (default nathan@n8n.io / PlaywrightTest123 only works on an E2E-bootstrapped instance).
  2. Confirm the target instance permits password login and is reachable at --base-url.
  3. If behind a proxy, ensure Set-Cookie headers are forwarded.
Defensive patterns

Strategy: retry

Validate before calling

if (!process.env.N8N_EVAL_EMAIL || !process.env.N8N_EVAL_PASSWORD)
  throw new Error('Set N8N_EVAL_EMAIL/N8N_EVAL_PASSWORD or pass credentials');

Try / catch

try { await client.login(); }
catch (e) {
  if (e instanceof Error && e.message.includes('no session cookie')) { /* verify creds + base-url, retry once */ }
  else throw e;
}

Prevention

When it happens

Trigger: Wrong N8N_EVAL_EMAIL/N8N_EVAL_PASSWORD; the n8n instance is not the E2E-bootstraped one (no nathan@n8n.io owner); SSO/LDAP enabled so password login is disabled; cookie domain mismatch.

Common situations: Pointing --base-url at an instance that uses SAML/LDAP only; running before the E2E bootstrap created the test owner; proxy stripping Set-Cookie headers.

Understand the failure class

Related errors


AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12). Data as JSON: /api/errors/bb51cfdfc67928f3. Report an issue: GitHub.