{"record":{"id":"bb51cfdfc67928f3","repo":"n8n-io/n8n","slug":"failed-to-authenticate-with-n8n-no-session-cooki","errorCode":null,"errorMessage":"Failed to authenticate with n8n — no session cookie received","messagePattern":"Failed to authenticate with n8n — no session cookie received","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/@n8n/instance-ai/evaluations/clients/n8n-client.ts","lineNumber":225,"sourceCode":"\n\t// -- Auth ----------------------------------------------------------------\n\n\t/**\n\t * Authenticate with the n8n instance via POST /rest/login.\n\t * Captures the `n8n-auth` cookie for subsequent requests.\n\t */\n\tasync login(email?: string, password?: string): Promise<void> {\n\t\t// Defaults match the E2E test owner created by the E2E_TESTS=true bootstrap\n\t\tconst loginEmail = email ?? process.env.N8N_EVAL_EMAIL ?? 'nathan@n8n.io';\n\t\tconst loginPassword = password ?? process.env.N8N_EVAL_PASSWORD ?? 'PlaywrightTest123';\n\n\t\tawait this.fetch('/rest/login', {\n\t\t\tmethod: 'POST',\n\t\t\tbody: { emailOrLdapLoginId: loginEmail, password: loginPassword },\n\t\t});\n\n\t\tif (!this.sessionCookie) {\n\t\t\tthrow new Error('Failed to authenticate with n8n — no session cookie received');\n\t\t}\n\t}\n\n\t// -- Instance-AI endpoints -----------------------------------------------\n\n\t/**\n\t * Ensure a conversation thread exists before sending chat messages.\n\t * POST /rest/instance-ai/threads body: { threadId, projectId, source }\n\t */\n\tasync ensureThread(threadId: string, projectId?: string): Promise<void> {\n\t\tconst resolvedProjectId = projectId ?? (await this.getPersonalProjectId());\n\t\tawait this.fetch('/rest/instance-ai/threads', {\n\t\t\tmethod: 'POST',\n\t\t\tbody: {\n\t\t\t\tthreadId,\n\t\t\t\tprojectId: resolvedProjectId,\n\t\t\t\tsource: 'evals',\n\t\t\t\torigin: 'internal',","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/instance-ai/evaluations/clients/n8n-client.ts#L207-L243","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify the credentials (default nathan@n8n.io / PlaywrightTest123 only works on an E2E-bootstrapped instance).","Confirm the target instance permits password login and is reachable at --base-url.","If behind a proxy, ensure Set-Cookie headers are forwarded."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if (!process.env.N8N_EVAL_EMAIL || !process.env.N8N_EVAL_PASSWORD)\n  throw new Error('Set N8N_EVAL_EMAIL/N8N_EVAL_PASSWORD or pass credentials');","typeGuard":null,"tryCatchPattern":"try { await client.login(); }\ncatch (e) {\n  if (e instanceof Error && e.message.includes('no session cookie')) { /* verify creds + base-url, retry once */ }\n  else throw e;\n}","preventionTips":["Confirm the target instance allows password login before scripting against it.","Use the E2E bootstrap so the default owner exists.","Check Set-Cookie forwarding on any proxy."],"tags":["auth","network","n8n-api"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}